Skip to content

[stdlib] Dictionary.updateValue(_:,forKey:): Don’t overwrite the existing key #19592

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

Merged
merged 1 commit into from
Sep 27, 2018

Conversation

lorentey
Copy link
Member

(This is the second attempt, after #19500 was reverted.)

updateValue(_:, forKey:) currently replaces the old key, which is undocumented, unnecessary and somewhat surprising. The previous incarnation of Dictionary implemented updates this way because of a technical detail; this wrinkle is now eliminated.

rdar://problem/32144087

I know of no use cases where the old behavior was actually desirable; most/all practical code that would care about this seem to prefer to leave the old key in place.

…ting key

Replacing the old key with the new is unnecessary and somewhat surprising. It is also harmful to some usecases.

rdar://problem/32144087

# Conflicts:
#	stdlib/public/core/NativeDictionary.swift
@lorentey
Copy link
Member Author

@swift-ci please test

@lorentey
Copy link
Member Author

@swift-ci please test source compatibility

@lorentey
Copy link
Member Author

lorentey commented Sep 27, 2018

Merging. The source compat failure earlier evidently wasn't caused by this change.

(It is also still occurring on master -- #19594.)

@lorentey lorentey merged commit 8c8f822 into swiftlang:master Sep 27, 2018
@lorentey lorentey deleted the update-value-not-key2 branch September 27, 2018 23:42
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

Successfully merging this pull request may close these issues.

1 participant