Skip to content

Conversion does not work well with Tuple 23 and above. #18260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
takapi327 opened this issue Jul 20, 2023 · 1 comment Β· Fixed by #19186
Closed

Conversion does not work well with Tuple 23 and above. #18260

takapi327 opened this issue Jul 20, 2023 · 1 comment Β· Fixed by #19186

Comments

@takapi327
Copy link

takapi327 commented Jul 20, 2023

Hi there πŸ‘‹

Type Mismatch Error occurs when using Conversion with more than 23 Tuples.

β€» The "cats.Id" part can be anything.

Compiler version

3.3.0

Minimized code

import scala.deriving.Mirror
import cats.Id

def test[P <: Product](using mirror: Mirror.ProductOf[P])(tuples: Tuple.Map[mirror.MirroredElemTypes, Id]): Tuple.Map[mirror.MirroredElemTypes, Id] = tuples

given Conversion[Id[2], Id[Seq[2]]] = v => Seq(v)

Successful Patterns

case class Test(p1: 1, p2: Seq[2], p3: 3, p4: 4, p5: 5, p6: 6, p7: 7, p8: 8, p9: 9, p10: 10, p11: 11, p12: 12, p13: 13, p14: 14, p15: 15, p16: 16, p17: 17, p18: 18, p19: 19, p20: 20, p21: 21, p22: 22)

test[Test](Id[1](1), Id[2](2), Id[3](3), Id[4](4), Id[5](5), Id[6](6), Id[7](7), Id[8](8), Id[9](9), Id[10](10), Id[11](11), Id[12](12), Id[13](13), Id[14](14), Id[15](15), Id[16](16), Id[17](17), Id[18](18), Id[19](19), Id[20](20), Id[21](21), Id[22](22))

Failure Patterns

case class Test(p1: 1, p2: Seq[2], p3: 3, p4: 4, p5: 5, p6: 6, p7: 7, p8: 8, p9: 9, p10: 10, p11: 11, p12: 12, p13: 13, p14: 14, p15: 15, p16: 16, p17: 17, p18: 18, p19: 19, p20: 20, p21: 21, p22: 22, p23: 23)

test[Test](Id[1](1), Id[2](2), Id[3](3), Id[4](4), Id[5](5), Id[6](6), Id[7](7), Id[8](8), Id[9](9), Id[10](10), Id[11](11), Id[12](12), Id[13](13), Id[14](14), Id[15](15), Id[16](16), Id[17](17), Id[18](18), Id[19](19), Id[20](20), Id[21](21), Id[22](22), Id[23](23))

Output

Successful Patterns

val res6: (cats.Id[1], cats.Id[Seq[2]], cats.Id[3], cats.Id[4], cats.Id[5],
  cats.Id[6], cats.Id[7], cats.Id[8], cats.Id[9], cats.Id[10], cats.Id[11],
  cats.Id[12], cats.Id[13], cats.Id[14], cats.Id[15], cats.Id[16], cats.Id[17],
  cats.Id[18], cats.Id[19], cats.Id[20], cats.Id[21], cats.Id[22]) = (1,List(2),3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22)

Failure Patterns

-- [E007] Type Mismatch Error: -------------------------------------------------
1 |test[Test](Id[1](1), Id[2](2), Id[3](3), Id[4](4), Id[5](5), Id[6](6), Id[7](7), Id[8](8), Id[9](9), Id[10](10), Id[11](11), Id[12](12), Id[13](13), Id[14](14), Id[15](15), Id[16](16), Id[17](17), Id[18](18), Id[19](19), Id[20](20), Id[21](21), Id[22](22), Id[23](23))
  |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |Found:    (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int,
  |  Int, Int, Int, Int, Int, Int, Int, Int)
  |Required: Tuple.Map[
  |  ((1 : Int), Seq[(2 : Int)], (3 : Int), (4 : Int), (5 : Int), (6 : Int),
  |    (7 : Int), (8 : Int), (9 : Int), (10 : Int), (11 : Int), (12 : Int),
  |    (13 : Int), (14 : Int), (15 : Int), (16 : Int), (17 : Int), (18 : Int),
  |    (19 : Int), (20 : Int), (21 : Int), (22 : Int), (23 : Int)),
  |cats.Id]
  |
  | longer explanation available when compiling with `-explain`
1 error found

Expectation

Since Scala3 no longer has a Tuple limit, we hope that more than 23 Tuples will be successful without any problems.

@takapi327 takapi327 added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Jul 20, 2023
@jchyb jchyb added area:typer area:typeclass-derivation area:tuples and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Jul 21, 2023
@jchyb
Copy link
Contributor

jchyb commented Jul 21, 2023

More self-contained minimization:

import scala.deriving.Mirror

type Id[A] = A
object Id:
  def apply[A](a: A): Id[A] = a

def test[P <: Product](using mirror: Mirror.ProductOf[P])(tuples: Tuple.Map[mirror.MirroredElemTypes, Id]): Tuple.Map[mirror.MirroredElemTypes, Id] = tuples

def main() =
  case class Test(p1: 1, p2: 2, p3: 3, p4: 4, p5: 5, p6: 6, p7: 7, p8: 8, p9: 9, p10: 10, p11: 11, p12: 12, p13: 13, p14: 14, p15: 15, p16: 16, p17: 17, p18: 18, p19: 19, p20: 20, p21: 21, p22: 22, p23: 23)
  test[Test](Id[1](1), Id[2](2), Id[3](3), Id[4](4), Id[5](5), Id[6](6), Id[7](7), Id[8](8), Id[9](9), Id[10](10), Id[11](11), Id[12](12), Id[13](13), Id[14](14), Id[15](15), Id[16](16), Id[17](17), Id[18](18), Id[19](19), Id[20](20), Id[21](21), Id[22](22), Id[23](23))

nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Dec 4, 2023
nicolasstucki added a commit that referenced this issue Jan 14, 2024
@Kordyjan Kordyjan added this to the 3.4.1 milestone Feb 14, 2024
WojciechMazur pushed a commit that referenced this issue Jun 27, 2024
WojciechMazur added a commit that referenced this issue Jun 28, 2024
Backports #19186 to the LTS branch.

PR submitted by the release tooling.
[skip ci]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants