From 5279e48afb2a174b42e75a1e700b6c62c7884926 Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Wed, 5 Sep 2018 17:49:57 -0400 Subject: [PATCH] fix #28900, macro hygiene bug inside keyword arg values (#29043) (cherry picked from commit 1fb86d2dae91dbd96ac43011468236380f1ac021) --- src/macroexpand.scm | 4 ++-- test/syntax.jl | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/macroexpand.scm b/src/macroexpand.scm index abad3407656fd..d95e8132ff21e 100644 --- a/src/macroexpand.scm +++ b/src/macroexpand.scm @@ -379,12 +379,12 @@ ;; in keyword arg A=B, don't transform "A" (unescape (cadr (cadr e)))) ,(resolve-expansion-vars- (caddr (cadr e)) env m parent-scope inarg)) - ,(resolve-expansion-vars- (caddr e) env m parent-scope inarg))) + ,(resolve-expansion-vars-with-new-env (caddr e) env m parent-scope inarg))) (else `(kw ,(if inarg (resolve-expansion-vars- (cadr e) env m parent-scope inarg) (unescape (cadr e))) - ,(resolve-expansion-vars- (caddr e) env m parent-scope inarg))))) + ,(resolve-expansion-vars-with-new-env (caddr e) env m parent-scope inarg))))) ((let) (let* ((newenv (new-expansion-env-for e env)) diff --git a/test/syntax.jl b/test/syntax.jl index 9e12206ad8325..250c73503a711 100644 --- a/test/syntax.jl +++ b/test/syntax.jl @@ -1673,3 +1673,14 @@ end @test A28593.var.name === :S @test B28593.var.name === :S @test C28593.var.name === :S + +# issue #28900 +macro foo28900(x) + quote + $x + end +end +f28900(; kwarg) = kwarg +let g = @foo28900 f28900(kwarg = x->2x) + @test g(10) == 20 +end