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 d97f5aeb251c8..ecb1a0e642424 100644 --- a/test/syntax.jl +++ b/test/syntax.jl @@ -2751,3 +2751,15 @@ end @test eval(:(x = $(QuoteNode(Core.SlotNumber(1))))) == Core.SlotNumber(1) @test_throws ErrorException("syntax: SSAValue objects should not occur in an AST") eval(:(x = $(Core.SSAValue(1)))) @test_throws ErrorException("syntax: Slot objects should not occur in an AST") eval(:(x = $(Core.SlotNumber(1)))) + +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