From cad5fc67ea61b559d908c77356831fe96f8881a1 Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Tue, 2 Jul 2019 09:59:53 -0400 Subject: [PATCH] fix the fix for #32121, more named tuple macro hygiene (#32464) (cherry picked from commit 07c2ecc2e904a18e0c4feedb63368cdd96a7bb02) --- src/macroexpand.scm | 11 +++++++++-- test/syntax.jl | 6 ++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/macroexpand.scm b/src/macroexpand.scm index 1c1502e477c74a..9e4a4a275b8664 100644 --- a/src/macroexpand.scm +++ b/src/macroexpand.scm @@ -419,7 +419,7 @@ (map (lambda (x) (if (assignment? x) `(= ,(unescape (cadr x)) - ,(resolve-expansion-vars-with-new-env x env m parent-scope inarg)) + ,(resolve-expansion-vars-with-new-env (caddr x) env m parent-scope inarg)) (resolve-expansion-vars-with-new-env x env m parent-scope inarg))) (cdr e)))) @@ -496,10 +496,17 @@ ((and (eq? (car e) '=) (not (function-def? e))) (append! (filter symbol? (decl-vars* (cadr e))) (find-assigned-vars-in-expansion (caddr e) #f))) + ((eq? (car e) 'tuple) + (apply append! (map (lambda (x) + (find-assigned-vars-in-expansion (if (assignment? x) + (caddr x) + x) + #f)) + (cdr e)))) (else (apply append! (map (lambda (x) (find-assigned-vars-in-expansion x #f)) - e))))) + (cdr e)))))) (define (keywords-introduced-by e) (let ((v (pattern-expand1 keywords-introduced-by-patterns e))) diff --git a/test/syntax.jl b/test/syntax.jl index 75321b5a6f07bd..bd552ab2b48aee 100644 --- a/test/syntax.jl +++ b/test/syntax.jl @@ -1762,3 +1762,9 @@ end let f = capture_with_conditional_label() # should not throw @test_throws UndefVarError(:x) f(0) end + +# issue #32121 +@test @id28992((a=1, b=2)) === (a=1, b=2) +a32121 = 8 +b32121 = 9 +@test @id28992((a32121=a32121, b32121=b32121)) === (a32121=8, b32121=9)