Skip to content

Commit

Permalink
fix macro hygiene for kwargs with name conflicts (#34329)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson authored Jan 10, 2020
1 parent c330f8d commit edc1b7d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/macroexpand.scm
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,9 @@
(append!
pairs
(filter (lambda (v) (not (assq (car v) env)))
(append!
(pair-with-gensyms v)
(map (lambda (v) (cons v v))
(diff (keywords-introduced-by x) globals))))
(pair-with-gensyms v))
(map (lambda (v) (cons v v))
(keywords-introduced-by x))
env)))))))

(define (resolve-expansion-vars-with-new-env x env m parent-scope inarg (outermost #f))
Expand Down
15 changes: 15 additions & 0 deletions test/syntax.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1971,3 +1971,18 @@ end
# issue #33987
f33987(args::(Vararg{Any, N} where N); kwargs...) = args
@test f33987(1,2,3) === (1,2,3)

macro id_for_kwarg(x); x; end
Xo65KdlD = @id_for_kwarg let x = 1
function f(; x)
x
end
end
@test_throws UndefKeywordError(:x) Xo65KdlD()
i0xb23hG = @id_for_kwarg let x = 1
function f(; x=2)
x
end
end
@test i0xb23hG() == 2
@test i0xb23hG(x=10) == 10

2 comments on commit edc1b7d

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily benchmark build, I will reply here when finished:

@nanosoldier runbenchmarks(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan

Please sign in to comment.