diff --git a/src/julia-syntax.scm b/src/julia-syntax.scm index 69036d33f8071..bd2bc211bd628 100644 --- a/src/julia-syntax.scm +++ b/src/julia-syntax.scm @@ -1906,7 +1906,7 @@ ,(expand-update-operator op op= (car e) rhs T)))) (else (if (and (pair? lhs) (eq? op= '=) - (not (memq (car lhs) '(|.| tuple vcat ncat typed_hcat typed_vcat typed_ncat)))) + (not (memq (car lhs) '(|.| globalref tuple vcat ncat typed_hcat typed_vcat typed_ncat)))) (error (string "invalid assignment location \"" (deparse lhs) "\""))) (expand-update-operator- op op= lhs rhs declT)))) diff --git a/test/syntax.jl b/test/syntax.jl index 1f5cdb34b3eb1..af5d7ce5e50e8 100644 --- a/test/syntax.jl +++ b/test/syntax.jl @@ -2602,6 +2602,15 @@ end @test ncalls_in_lowered(:((.+)(a, b .- (.^)(c, 2))), GlobalRef(Base, :BroadcastFunction)) == 0 end +module M59008 # dotop with global LHS in macro +using Test +global a = 1 +macro counter() + :(a += 1) +end +@test @counter() === 2 === a +end + # issue #37656 @test :(if true 'a' else 1 end) == Expr(:if, true, quote 'a' end, quote 1 end)