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

Fails to find given instance of type NamedTuple.Map without use of type alias #20377

Open
aherlihy opened this issue May 10, 2024 · 0 comments
Open
Labels

Comments

@aherlihy
Copy link
Contributor

aherlihy commented May 10, 2024

Compiler version

3.5.0-RC1-bin-SNAPSHOT (b10d64e)

Minimized code

import language.experimental.namedTuples
import NamedTuple.{NamedTuple, AnyNamedTuple}

// Repros for bugs or questions
class ClassToMap[A]()
abstract class ClassToFind[Rows <: AnyNamedTuple]:
  def mapped: NamedTuple.Map[Rows, ClassToMap]

given TDB: ClassToFind[(t1: Int, t2: String)] with
  override def mapped = (
    t1 = ClassToMap[Int](),
    t2 = ClassToMap[String]()
  )

type TypeAlias = (t1: Int, t2: String)
class Repro1_Pass(using val testDB: ClassToFind[TypeAlias]) {
  def query() =
    testDB.mapped.t1
}
class Repro1_Fail(using val testDB: ClassToFind[(t1: Int, t2: String)]) {
  def query() =
    testDB.mapped.t1 // fails to compile
}

Output

[error] 25 |    testDB.mapped.t1 // fails to compile
[error]    |    ^^^^^^^^^^^^^
[error]    |Found:    (x$proxy3 :
[error]    |  (Repro1_Fail.this.testDB.mapped :
[error]    |    => NamedTuple.Map[(t1 : Int, t2 : String), repro.ClassToMap])
[error]    | &
[error]    |  $proxy3.NamedTuple[
[error]    |    NamedTupleDecomposition.Names[
[error]    |      $proxy3.NamedTuple[(("t1" : String), ("t2" : String)), (Int, String)]],
[error]    |    Tuple.Map²[
[error]    |      NamedTupleDecomposition.DropNames[
[error]    |        $proxy3.NamedTuple[(("t1" : String), ("t2" : String)), (Int, String)]],
[error]    |      repro.ClassToMap]
[error]    |  ]
[error]    |)
[error]    |Required: (repro.ClassToMap[Int], repro.ClassToMap[String])

Expectation

It's unexpected that using a type alias enables the given instance to be found, but using the named tuple type directly does not.

@aherlihy aherlihy added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels May 10, 2024
@Gedochao Gedochao added area:experimental 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 May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants