Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

give a syntax error for repeated keyword args. fixes #16937 #21780

Merged
merged 1 commit into from
May 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ This section lists changes that do not have deprecation warnings.
* `@__DIR__` returns the current working directory rather than `nothing` when not run
from a file ([#21759]).

* Passing the same keyword argument multiple times is now a syntax error ([#16937]).


Library improvements
--------------------
Expand Down
5 changes: 5 additions & 0 deletions src/julia-syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -1439,6 +1439,11 @@
;; lower function call containing keyword arguments
(define (lower-kw-call fexpr kw0 pa)

;; check for keyword arguments syntactically passed more than once
(let ((dups (has-dups (map cadr (filter kwarg? kw0)))))
(if dups
(error (string "keyword argument \"" (car dups) "\" repeated in call to \"" (deparse fexpr) "\""))))

(define (kwcall-unless-empty f pa kw-container-test kw-container)
(let* ((expr_stmts (remove-argument-side-effects `(call ,f ,@pa)))
(pa (cddr (car expr_stmts)))
Expand Down
4 changes: 4 additions & 0 deletions test/parse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1187,3 +1187,7 @@ module Test21607
x
end === 1.0
end

# issue #16937
@test expand(:(f(2, a=1, w=3, c=3, w=4, b=2))) == Expr(:error,
"keyword argument \"w\" repeated in call to \"f\"")