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

Fix ImmutableDict(:a => 1, :a => 2)[:a] #35871

Merged
merged 1 commit into from
May 15, 2020

Conversation

tkf
Copy link
Member

@tkf tkf commented May 13, 2020

Currently, the behavior of Dict(pairs...) and
Base.ImmutableDict(pairs...) are different:

julia> Dict(:a => 1, :a => 2)[:a]
2

julia> Base.ImmutableDict(:a => 1, :a => 2)[:a]
1

This PR fixes the latter to return 2.

cc @simeonschaub

As I think this is a bug fix and this feature did not exist in 1.4, I add the backport label.

Currently, the behavior of `Dict(pairs...)` and
`Base.ImmutableDict(pairs...)` are different:

    julia> Dict(:a => 1, :a => 2)[:a]
    2

    julia> Base.ImmutableDict(:a => 1, :a => 2)[:a]
    1

This PR fixes the latter to return 2.
@tkf tkf added bugfix This change fixes an existing bug backport 1.5 labels May 13, 2020
Copy link
Member

@simeonschaub simeonschaub left a comment

Choose a reason for hiding this comment

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

It's a bit unfortunate that collect(ImmutableDict(v...)) == v doesn't hold anymore, but I agree that being consistent with the Dict constructor here is more important.

@tkf tkf changed the title Left fold ImmutableDict(args::Pair...) Fix ImmutableDict(:a => 1, :a => 2)[:a] May 13, 2020
@JeffBezanson JeffBezanson merged commit fe59346 into JuliaLang:master May 15, 2020
@tkf tkf deleted the foldl-ImmutableDict branch May 15, 2020 18:57
KristofferC pushed a commit that referenced this pull request May 19, 2020
Currently, the behavior of `Dict(pairs...)` and
`Base.ImmutableDict(pairs...)` are different:

    julia> Dict(:a => 1, :a => 2)[:a]
    2

    julia> Base.ImmutableDict(:a => 1, :a => 2)[:a]
    1

This PR fixes the latter to return 2.

(cherry picked from commit fe59346)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix This change fixes an existing bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants