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

Splatted keywords take precedence #17785

Closed
omus opened this issue Aug 3, 2016 · 2 comments
Closed

Splatted keywords take precedence #17785

omus opened this issue Aug 3, 2016 · 2 comments
Assignees

Comments

@omus
Copy link
Member

omus commented Aug 3, 2016

When combining specified keywords and splatted keywords the splatted keywords are always used. Similar to #16937.

julia> g(; a=1, b=2) = a, b
g (generic function with 1 method)

julia> opts = (:a => 3, :b => 4)
(:a=>3,:b=>4)

julia> g(; opts...)
(3,4)

julia> g(; a=5, opts...)
(3,4)

julia> g(; opts..., a=5)
(3,4)

julia> g(; a=5)
(5,2)

Occurs in both 0.4.6 and 0.5.

@iamed2
Copy link
Contributor

iamed2 commented Aug 3, 2016

On the other hand:

julia> opts = (:a=>3,:b=>4,:a=>5); g(; opts...)
(5,4)

This is not quite #16937 as it isn't a syntax issue and wouldn't be the same mistake. This could be the result of the merge call mentioned in that thread, and is probably intentional.

IMO the ideal result is that the rightmost kwarg takes precedent in all cases, whether it is part of a splat or not.

@JeffBezanson
Copy link
Member

Yes, I think this could easily be changed to make everything left-to-right.

@JeffBezanson JeffBezanson self-assigned this Aug 3, 2016
JeffBezanson added a commit that referenced this issue Aug 3, 2016
Whatever comes later, whether splatted or not, takes precedence.
JeffBezanson added a commit that referenced this issue Aug 9, 2016
fix #17785, process all keyword args left-to-right
mfasi pushed a commit to mfasi/julia that referenced this issue Sep 5, 2016
Whatever comes later, whether splatted or not, takes precedence.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants