Skip to content

Inlined mapping function fails when an inlined match is used #14325

Open
@hmf

Description

@hmf

Compiler version

3.1.0

Minimized code

val t1          = ( 1,   2L,  3.0f,   4.0,    "five",    '6'   )
val csvStandard = ("1", "2", "3.0",  "4.0", "\"five\"",  "6"   )

inline def toCSV: [t] => t => String = [t] => (x: t) => x match {
  case x: String => s"\"$x\""
  case x:_ => x.toString
}

val t1o3 = t1.map[[t] =>> String](toCSV)
println(t1o3)

works and prints

(1,2,3.0,4.0,"five",6)

But this does not (inline match):

val t1          = ( 1,   2L,  3.0f,   4.0,    "five",    '6'   )
val csvStandard = ("1", "2", "3.0",  "4.0", "\"five\"",  "6"   )

inline def toCSV: [t] => t => String = [t] => (x: t) => x match {
  case x: String => s"\"$x\""
  case x:_ => x.toString
}

val t1o3 = t1.map[[t] =>> String](toCSV)
println(t1o3)

Output

In the case above I get:

(1,2,3.0,4.0,five,6)

It seems like no type information is available for use. The default case is used.

Expectation

I was expecting to have the same output. If this is to be expected then I have seen several open issues regarding matching tuples inline, but cannot say if this is the same issue.

Note: I tried to create scastie example but failed due to a compilation error on the latest and RC versions.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions