Open st33v3 opened 4 months ago
The underlying issue seems to be a bug in inlining/typing and can be triggered with -Ycheck:inlining
.
Slightly smaller minimization:
// i21176_1.scala
import scala.quoted.*
class Macro:
inline def nameTuple[NameTuple_T]: (String, List[NameTuple_T]) = Macro.tuple[NameTuple_T](Macro.named)
object Macro:
def namedMacro(using q: Quotes): Expr[String] = Expr("test")
inline def named: String = ${Macro.namedMacro}
def tuple[Tuple_T](name: String): (String, List[Tuple_T]) = (name, List.empty[Tuple_T])
//> using scala 3.nightly
//> using options -Ycheck:inlining
// i21176_2.scala
class Test extends Macro:
val abc = nameTuple[Int]
Error:
Thank you @KacperFKorban . Indeed, the phase safe-init
gets an incorrect tree --- probably related inlining. I changed it to a meta-programming issue.
Compiler version
compiler version: version 3.4.2 settings: -Ysafe-init true
Minimized code
Output (click arrow to expand)