From d3ab951631e4b47409331990814383511c884a01 Mon Sep 17 00:00:00 2001 From: Michiel Dral Date: Thu, 10 Jul 2025 16:44:38 -0700 Subject: [PATCH] Fix `hygienic-scope`s in inner macro expansions Changes from https://github.com/JuliaLang/julia/pull/43151. --- src/macroexpand.scm | 2 +- test/core.jl | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/macroexpand.scm b/src/macroexpand.scm index f67145317dc7a..2990d98eefe6e 100644 --- a/src/macroexpand.scm +++ b/src/macroexpand.scm @@ -513,7 +513,7 @@ (body (cadr e)) (m (caddr e)) (lno (cdddr e))) - (resolve-expansion-vars-with-new-env body env m lno parent-scope inarg #t))) + (resolve-expansion-vars-with-new-env body '() m lno parent-scope inarg #t))) ((tuple) (cons (car e) (map (lambda (x) diff --git a/test/core.jl b/test/core.jl index a824c0abb674a..4af61233ac458 100644 --- a/test/core.jl +++ b/test/core.jl @@ -2280,6 +2280,31 @@ end x6074 = 6074 @test @X6074() == 6074 +# issues #48910, 54417 +macro X43151_nested() + quote my_value = "from_nested_macro" end +end +macro X43151_parent() + quote + my_value = "from_parent_macro" + @X43151_nested() + my_value + end +end +@test @X43151_parent() == "from_parent_macro" + +macro X43151_nested_escaping() + quote $(esc(:my_value)) = "from_nested_macro" end +end +macro X43151_parent_escaping() + quote + my_value = "from_parent_macro" + @X43151_nested_escaping() + my_value + end +end +@test @X43151_parent_escaping() == "from_nested_macro" + # issue #5536 test5536(a::Union{Real, AbstractArray}...) = "Splatting" test5536(a::Union{Real, AbstractArray}) = "Non-splatting"