Skip to content

Scenario with Selectable, Tuple.Map, and named tuple, where field is not selectable #22645

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
kavedaa opened this issue Feb 23, 2025 · 1 comment
Assignees
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:  //  fails

  class SelectableNT[N <: Tuple] extends Selectable:   
    def selectDynamic(name: String) = ???
    type Names = Tuple.Map[N, [X] =>> X] 
    type Fields = NamedTuple.NamedTuple[Names, (String, Int)]

  val x = new SelectableNT[("name", "age")]
  x.name  // fails


object ExhibitB:  //  works

  class SelectableNT[N <: Tuple] extends Selectable:   
    def selectDynamic(name: String) = ???
    type Fields = NamedTuple.NamedTuple[N, (String, Int)]

  val x = new SelectableNT[("name", "age")]
  x.name  


object ExhibitC:  // works

  class SelectableNT[N <: Tuple] extends Selectable:   
    def selectDynamic(name: String) = ???
    type Fields = NamedTuple.NamedTuple[N, (String, Int)]

  type N = ("name", "age")
  val x = new SelectableNT[N]
  x.name 


object ExhibitD:  // works

  class SelectableNT[N <: Tuple] extends Selectable:   
    def selectDynamic(name: String) = ???
    type Fields = NamedTuple.NamedTuple[N, (String, Int)]

  type N = ("name", "age")
  type Names = Tuple.Map[N, [X] =>> X]
  val x = new SelectableNT[Names]
  x.name


object ExhibitE:  // works

  type N = ("name", "age")
  type Names = Tuple.Map[N, [X] =>> X]

  class SelectableNT extends Selectable:   
    def selectDynamic(name: String) = ???
    type Fields = NamedTuple.NamedTuple[Names, (String, Int)]

  val x = new SelectableNT
  x.name

Output

[error] .\bug.scala:15:3
[error] value name is not a member of bug.ExhibitA.SelectableNT[(("name" : String), ("age" : String))]
[error]   x.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
aherlihy added a commit to aherlihy/scala3 that referenced this issue Apr 16, 2025
@bracevac
Copy link
Contributor

This has been fixed by #23005

tgodzik pushed a commit to scala/scala3-lts that referenced this issue Apr 28, 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

3 participants