- Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
area:metaprogramming:quotesIssues related to quotes and splicesIssues related to quotes and splicesitype:bug
Description
Compiler version
3.1.2, 3.1.3-RC3, 3.2.0-RC1-bin-20220517-e5abec0-NIGHTLY
Minimized code
The gist of the code is, that it uses an ExprMap
to collect all subexpressions. It does that twice, and the compares the found expressions.
import scala.quoted.* inline def mac[T](inline expr: T): T = ${ impl('expr) } class MyMap() extends ExprMap { var expressions: List[Expr[Any]] = Nil override def transform[T](e: Expr[T])(using Type[T])(using q: Quotes): Expr[T] = expressions ::= e transformChildren(e) } def impl[T: Type](expr: Expr[T])(using quotes: Quotes): Expr[T] = { val List(es1, es2) = List(MyMap(), MyMap()).map { m => m.transform(expr) m.expressions } assert(es1 == es2) assert(es1.map(_.hashCode()) == es2.map(_.hashCode()), s"hash codes not equal:\n${es1.map(_.hashCode())}\n${es2.map(_.hashCode())}") expr }
then call the macro in another file with any expression, say mac(1)
Output
[error] java.lang.AssertionError: assertion failed: hash codes not equal: [error] List(290429894, 1544224853) [error] List(1268450819, 1544224853)
Expectation
the expressions of the two runs are are equal, so the hashcodes should also be equal
Metadata
Metadata
Assignees
Labels
area:metaprogramming:quotesIssues related to quotes and splicesIssues related to quotes and splicesitype:bug