Skip to content

Commit f5f5105

Browse files
authored
Merge pull request #15247 from dotty-staging/fix-15213
Transform RHS of captured assignment reference
2 parents 95ae793 + 8461727 commit f5f5105

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

compiler/src/dotty/tools/dotc/transform/Splicing.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ class Splicing extends MacroTransform:
294294
reflect.asExpr(tree.tpe)(
295295
reflect.Assign(
296296
reflect.asTerm(capturedTerm(tree.lhs)),
297-
reflect.asTerm(quoted(tree.rhs))
297+
reflect.asTerm(quoted(transform(tree.rhs)))
298298
)
299299
)
300300
}

tests/pos-macros/i15213.scala

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import scala.quoted.*
2+
3+
def map[T](arr: Expr[Array[T]], f: Expr[T] => Expr[Unit])(using Type[T], Quotes): Expr[Unit] = '{}
4+
5+
def sum(arr: Expr[Array[Int]])(using Quotes): Expr[Int] = '{
6+
var sum = 0
7+
${ map(arr, x => '{sum += $x}) }
8+
sum
9+
}

0 commit comments

Comments
 (0)