diff --git a/src/macroexpand.scm b/src/macroexpand.scm index 882fe88a2e648..a0f05a3af687a 100644 --- a/src/macroexpand.scm +++ b/src/macroexpand.scm @@ -324,7 +324,7 @@ m parent-scope inarg)) (define (resolve-expansion-vars- e env m parent-scope inarg) - (cond ((or (eq? e 'end) (eq? e 'ccall) (eq? e 'cglobal)) + (cond ((or (eq? e 'begin) (eq? e 'end) (eq? e 'ccall) (eq? e 'cglobal) (underscore-symbol? e)) e) ((symbol? e) (let ((a (assq e env))) diff --git a/test/syntax.jl b/test/syntax.jl index eb113ed4da2c5..1d6193b2f2634 100644 --- a/test/syntax.jl +++ b/test/syntax.jl @@ -2674,3 +2674,15 @@ end == 4 @test ncalls_in_lowered(:(.!(1 .< A .< 2)), GlobalRef(Base, :materialize)) == 1 @test ncalls_in_lowered(:((.!)(1 .< A .< 2)), GlobalRef(Base, :materialize)) == 1 end + +macro m_underscore_hygiene() + return :(_ = 1) +end + +@test @macroexpand(@m_underscore_hygiene()) == :(_ = 1) + +macro m_begin_hygiene(a) + return :($(esc(a))[begin]) +end + +@test @m_begin_hygiene([1, 2, 3]) == 1