Skip to content

Commit

Permalink
fix the fix for #32121, more named tuple macro hygiene (#32464)
Browse files Browse the repository at this point in the history
(cherry picked from commit 07c2ecc)
  • Loading branch information
JeffBezanson authored and KristofferC committed Aug 28, 2019
1 parent 944f84c commit fc33508
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/macroexpand.scm
Original file line number Diff line number Diff line change
Expand Up @@ -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))))

Expand Down Expand Up @@ -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)))
Expand Down
14 changes: 14 additions & 0 deletions test/syntax.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1762,3 +1762,17 @@ end
let f = capture_with_conditional_label() # should not throw
@test_throws UndefVarError(:x) f(0)
end

# issue #28992
macro id28992(x) x end
@test @id28992(1 .+ 2) == 3
@test Meta.isexpr(Meta.lower(@__MODULE__, :(@id28992((.+)(a,b) = 0))), :error)
@test @id28992([1] .< [2] .< [3]) == [true]
@test @id28992(2 ^ -2) == 0.25
@test @id28992(2 .^ -2) == 0.25

# 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)

0 comments on commit fc33508

Please sign in to comment.