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

Named Tuple element not selectable when name comes from type alias #21300

Closed
kavedaa opened this issue Jul 30, 2024 · 0 comments · Fixed by #21331
Closed

Named Tuple element not selectable when name comes from type alias #21300

kavedaa opened this issue Jul 30, 2024 · 0 comments · Fixed by #21331
Assignees
Labels
area:experimental:named-tuples Issues tied to the named tuples feature. itype:bug
Milestone

Comments

@kavedaa
Copy link

kavedaa commented Jul 30, 2024

Compiler version

3.5.0-RC4 and others

Minimized code

//> using scala 3.5.0-RC4, 3.nightly

import scala.language.experimental.namedTuples

class Test[S <: String & Singleton](name: S):

  type NT = NamedTuple.NamedTuple[Tuple1[S], Tuple1[Int]]
  def nt: NT = ???

  type Name = S
  
  type NT2 = NamedTuple.NamedTuple[Tuple1[Name], Tuple1[Int]]
  def nt2: NT2 = ???

@main def main =

  val foo = new Test("bar")
  
  foo.nt.bar	//	works
  foo.nt2.bar	//	fails

Output

Compiling project (Scala 3.5.0-RC4, JVM (8))
[error] .\test.scala:21:11
[error] Malformed NamedTuple: names must be string types, but foo.Name was found.
[error]   foo.nt2.bar   //      fails
[error]           ^
Error compiling project (Scala 3.5.0-RC4, JVM (8))

Expectation

Successful compilation.

@kavedaa kavedaa added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Jul 30, 2024
@Gedochao Gedochao added area:experimental: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 Aug 5, 2024
@KacperFKorban KacperFKorban self-assigned this Aug 5, 2024
@WojciechMazur WojciechMazur added this to the 3.5.2 milestone Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:experimental:named-tuples Issues tied to the named tuples feature. itype:bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants