From 517b8cea643cef8b219682acf8739613f49fb140 Mon Sep 17 00:00:00 2001 From: Michiel Dral Date: Fri, 19 Nov 2021 01:39:15 +0000 Subject: [PATCH 1/2] In nested macros, ignore locals in the outer macro when gensym-ing the inner macro --- src/macroexpand.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/macroexpand.scm b/src/macroexpand.scm index 34414d24bde75..6d33ef89febe3 100644 --- a/src/macroexpand.scm +++ b/src/macroexpand.scm @@ -438,7 +438,7 @@ (let ((parent-scope (cons (list env m) parent-scope)) (body (cadr e)) (m (caddr e))) - (resolve-expansion-vars-with-new-env body env m parent-scope inarg #t))) + (resolve-expansion-vars-with-new-env body '() m parent-scope inarg #t))) ((tuple) (cons (car e) (map (lambda (x) From b59aac0514b7568edb923b1d822be75c29c98e0c Mon Sep 17 00:00:00 2001 From: Michiel Dral Date: Fri, 19 Nov 2021 11:55:13 +0000 Subject: [PATCH 2/2] Tests for PR #43151 --- test/core.jl | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/core.jl b/test/core.jl index 3727d3ff8f069..c37e94f184b51 100644 --- a/test/core.jl +++ b/test/core.jl @@ -2056,6 +2056,32 @@ end x6074 = 6074 @test @X6074() == 6074 +# issue #43151 +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" + +# also issue #43151 +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"