Skip to content

Commit fc33508

Browse files
JeffBezansonKristofferC
authored andcommitted
fix the fix for #32121, more named tuple macro hygiene (#32464)
(cherry picked from commit 07c2ecc)
1 parent 944f84c commit fc33508

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

src/macroexpand.scm

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@
419419
(map (lambda (x)
420420
(if (assignment? x)
421421
`(= ,(unescape (cadr x))
422-
,(resolve-expansion-vars-with-new-env x env m parent-scope inarg))
422+
,(resolve-expansion-vars-with-new-env (caddr x) env m parent-scope inarg))
423423
(resolve-expansion-vars-with-new-env x env m parent-scope inarg)))
424424
(cdr e))))
425425

@@ -496,10 +496,17 @@
496496
((and (eq? (car e) '=) (not (function-def? e)))
497497
(append! (filter symbol? (decl-vars* (cadr e)))
498498
(find-assigned-vars-in-expansion (caddr e) #f)))
499+
((eq? (car e) 'tuple)
500+
(apply append! (map (lambda (x)
501+
(find-assigned-vars-in-expansion (if (assignment? x)
502+
(caddr x)
503+
x)
504+
#f))
505+
(cdr e))))
499506
(else
500507
(apply append! (map (lambda (x)
501508
(find-assigned-vars-in-expansion x #f))
502-
e)))))
509+
(cdr e))))))
503510

504511
(define (keywords-introduced-by e)
505512
(let ((v (pattern-expand1 keywords-introduced-by-patterns e)))

test/syntax.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1762,3 +1762,17 @@ end
17621762
let f = capture_with_conditional_label() # should not throw
17631763
@test_throws UndefVarError(:x) f(0)
17641764
end
1765+
1766+
# issue #28992
1767+
macro id28992(x) x end
1768+
@test @id28992(1 .+ 2) == 3
1769+
@test Meta.isexpr(Meta.lower(@__MODULE__, :(@id28992((.+)(a,b) = 0))), :error)
1770+
@test @id28992([1] .< [2] .< [3]) == [true]
1771+
@test @id28992(2 ^ -2) == 0.25
1772+
@test @id28992(2 .^ -2) == 0.25
1773+
1774+
# issue #32121
1775+
@test @id28992((a=1, b=2)) === (a=1, b=2)
1776+
a32121 = 8
1777+
b32121 = 9
1778+
@test @id28992((a32121=a32121, b32121=b32121)) === (a32121=8, b32121=9)

0 commit comments

Comments
 (0)