Skip to content

Commit 82ae530

Browse files
authored
Fix escaping of rhs for @atomic a.x = y (#41216)
1 parent 973e432 commit 82ae530

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

base/expr.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ function make_atomic(order, ex)
534534
elseif isexpr(ex, :call, 3)
535535
return make_atomic(order, ex.args[2], ex.args[1], ex.args[3])
536536
elseif ex.head === :(=)
537-
l, r = ex.args[1], ex.args[2]
537+
l, r = ex.args[1], esc(ex.args[2])
538538
if is_expr(l, :., 2)
539539
ll, lr = esc(l.args[1]), esc(l.args[2])
540540
return :(setproperty!($ll, $lr, $r, $order))

test/atomics.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,9 @@ let a = ARefxy(1, -1)
299299
@test 1 === @atomic a.x
300300
@test 2 === @atomic :sequentially_consistent a.x = 2
301301
@test 3 === @atomic :monotonic a.x = 3
302+
local four = 4
303+
@test 4 === @atomic :monotonic a.x = four
304+
@test 3 === @atomic :monotonic a.x = four - 1
302305
@test_throws ConcurrencyViolationError @atomic :not_atomic a.x = 2
303306
@test_throws ConcurrencyViolationError @atomic :not_atomic a.x
304307
@test_throws ConcurrencyViolationError @atomic :not_atomic a.x += 1

0 commit comments

Comments
 (0)