diff --git a/compiler/src/dotty/tools/dotc/transform/Splicing.scala b/compiler/src/dotty/tools/dotc/transform/Splicing.scala index a9b97ebff407..6035f18474f2 100644 --- a/compiler/src/dotty/tools/dotc/transform/Splicing.scala +++ b/compiler/src/dotty/tools/dotc/transform/Splicing.scala @@ -294,7 +294,7 @@ class Splicing extends MacroTransform: reflect.asExpr(tree.tpe)( reflect.Assign( reflect.asTerm(capturedTerm(tree.lhs)), - reflect.asTerm(quoted(tree.rhs)) + reflect.asTerm(quoted(transform(tree.rhs))) ) ) } diff --git a/tests/pos-macros/i15213.scala b/tests/pos-macros/i15213.scala new file mode 100644 index 000000000000..e06c259b64a9 --- /dev/null +++ b/tests/pos-macros/i15213.scala @@ -0,0 +1,9 @@ +import scala.quoted.* + +def map[T](arr: Expr[Array[T]], f: Expr[T] => Expr[Unit])(using Type[T], Quotes): Expr[Unit] = '{} + +def sum(arr: Expr[Array[Int]])(using Quotes): Expr[Int] = '{ + var sum = 0 + ${ map(arr, x => '{sum += $x}) } + sum +}