- Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
area:metaprogramming:quotesIssues related to quotes and splicesIssues related to quotes and splicesarea:metaprogramming:reflectionIssues related to the quotes reflection APIIssues related to the quotes reflection APIarea:named-tuplesIssues tied to the named tuples feature.Issues tied to the named tuples feature.itype:bug
Description
Compiler version
3.7.0-RC1
Minimized code
MacroNamedTuple.scala
//> using scala 3.7.0-RC1 //> using jvm temurin:23 import scala.quoted.* import scala.deriving.* object MacroNamedTuple: inline def tupleStringArg[T](t: T, arg: String) = ${tupleArg('t,'arg)} def tupleArg[T](t: Expr[T], arg: Expr[String])(using Quotes) = import quotes.reflect.* val sel = Select.unique(t.asTerm, arg.valueOrAbort) sel.asExprOf[String]
Example.scala
//> using scala 3.7.0-RC1 //> using jvm temurin:23 object Example: def main(args:Array[String]): Unit = val t = (name = "abc", v = 123) val str = MacroNamedTuple.tupleStringArg(t, "name") println(str)
Output
Running with:
scala-cli MacroNamedTuple.scala Example.scala
[error] ./Example.scala:7:46 [error] value name is not a member of (name : String, v : Int) [error] val str = MacroNamedTuple.tupleStringArg(t, "name")
Expectation
Should print "abc"
Changing Example to regular tuples works fine:
object Example: def main(args:Array[String]): Unit = val t = ("abc",123) val str = MacroNamedTuple.tupleStringArg(t, "_1") println(str)
Metadata
Metadata
Assignees
Labels
area:metaprogramming:quotesIssues related to quotes and splicesIssues related to quotes and splicesarea:metaprogramming:reflectionIssues related to the quotes reflection APIIssues related to the quotes reflection APIarea:named-tuplesIssues tied to the named tuples feature.Issues tied to the named tuples feature.itype:bug