Closed
Description
Compiler version
3.5-RC1, with #19174
Minimized example
import language.experimental.namedTuples
type TripleSingle = ("Lausanne", 1000, 140000)
type CitySingle = (name: "Lausanne", zip: 1000, pop: 140000)
@main def Test =
val tripleSingle: TripleSingle = ("Lausanne", 1000, 140000) // OK
val citySingle: CitySingle = (name = "Lausanne", zip = 1000, pop = 140000) // error
Output
-- [E007] Type Mismatch Error: named-tuple-single-ops.scala:8:31 ---------------
8 | val citySingle: CitySingle = (name = "Lausanne", zip = 1000, pop = 140000)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| Found: (name : String, zip : Int, pop : Int)
| Required: CitySingle
|
| longer explanation available when compiling with `-explain`
1 error found
Expectation
Singleton types in an expected named tuple type should be propagated to the right-hand side just as in the case for normal tuples.
This currently fails because named tuples expand to typelevel operations that perform too much widening. It's not yet clear whether we want to pursue a solution specific to named tuples or whether we want to improve the type-level possibilities for precise types first and then build on that.