Skip to content

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

Closed
@takapi327

Description

@takapi327

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions