Skip to content
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

Combination of trait, type alias, Tuple.Concat, and named tuple, where named tuple elements are not selectable #22643

Open
kavedaa opened this issue Feb 23, 2025 · 0 comments
Labels
area:named-tuples Issues tied to the named tuples feature. itype:bug

Comments

@kavedaa
Copy link

kavedaa commented Feb 23, 2025

Compiler version

3.6.3, 3.7.0-RC1-bin-20250222-4dc4668-NIGHTLY

Minimized code

package bug

import scala.language.experimental.namedTuples

object ExhibitA:

  trait Join[A <: Tuple, B <: Tuple]:
    type Names = Tuple.Concat[A, B]
    type NT = NamedTuple.NamedTuple[Names, (String, Int)]
    val nt: NT = ???

  val join: Join[Tuple1["name"], Tuple1["age"]] = ???

  join.nt.name    // fails

  
object ExhibitB:

  trait Join[A <: Tuple, B <: Tuple]:
    type NT = NamedTuple.NamedTuple[Tuple.Concat[A, B], (String, Int)]
    val nt: NT = ???

  val join: Join[Tuple1["name"], Tuple1["age"]] = ???

  join.nt.name    // works

    
object ExhibitC:

  type A = Tuple1["name"]
  type B = Tuple1["age"]

  type Names = Tuple.Concat[A, B]
  type NT = NamedTuple.NamedTuple[Names, (String, Int)]
  val nt: NT = ???

  nt.name   // works


object ExhibitD:

  trait Join[A, B]:
    type Names = (A, B)
    type NT = NamedTuple.NamedTuple[Names, (String, Int)]
    val nt: NT = ???

  val join: Join["name", "age"] = ???
  
  join.nt.name    // works

Output

[error] .\bug.scala:16:3
[error] value name is not a member of bug.ExhibitA.join.NT
[error]   join.nt.name    // fails
[error]   ^^^^^^^^^^^^

Expectation

Successful compilation

@kavedaa kavedaa added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Feb 23, 2025
@Gedochao Gedochao added area:named-tuples Issues tied to the named tuples feature. and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:named-tuples Issues tied to the named tuples feature. itype:bug
Projects
None yet
Development

No branches or pull requests

2 participants