Open
Description
Compiler version
3.7.1, 3.7.3-RC1-bin-20250620-d6b74fa-NIGHTLY
Minimized code
//file: Repro.scala
//> using scala 3.7.1
import scala.quoted.*
import NamedTuple.*
object Repro {
inline def run[Name <: String, Value](tup: NamedTuple[Tuple1[Name], Tuple1[Value]]) = ${ runMacro('tup) }
def runMacro[Name <: String: Type, Value: Type](expr: Expr[NamedTuple[Tuple1[Name], Tuple1[Value]]])(using Quotes) = {
import quotes.reflect.*
expr match {
case '{ $namedTup: NamedTuple[names, values] } => report.errorAndAbort("worky")
// checking if the types need to be constrained, but it doesn't seem to affect anything
case '{
type names <: scala.Tuple
type values <: scala.Tuple
$namedTup: NamedTuple[names, values]
} => report.errorAndAbort("worky")
case '{ $namedTup: AnyNamedTuple } => report.errorAndAbort("worky but only with AnyNamedTuple :(")
}
}
}
//file: test.scala
object test {
Repro.run((field1 = 123)) //outputs: 'worky but only with AnyNamedTuple'
}
Output
Compiling project (Scala 3.7.3-RC1-bin-20250620-d6b74fa-NIGHTLY, JVM (21))
[error] ./unableToMatchNamedTuple/test.scala:2:3
[error] worky but only with AnyNamedTuple :(
[error] Repro.run((field1 = 123))
[error] ^^^^^^^^^^^^^^^^^^^^^^^^^
Error compiling project (Scala 3.7.3-RC1-bin-20250620-d6b74fa-NIGHTLY, JVM (21))
Compilation failed
Expectation
The expr match should match on the first case (case '{ $namedTup: NamedTuple[names, values] }
) giving us access to the types of names
and values
.