-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
maps: document that DeleteFunc fails in presence of NaN keys #63312
Comments
I believe this is unfortunate but working as intended. |
I didn't see this documented either with maps.DeleteFunc, or with map types or clear. Maybe it should be? Aside: there's some possibly unfortunate language relating to min/max here: "assuming all NaNs are equal". NaNs are not equal - not even to themselves. But I believe that all NaNs are equivalent or fungible. |
The inequality of NaNs come from:
|
Yes I understand that. I was querying the language of the golang spec which says "assuming all NaNs are equal" |
We should document this behavior, if nothing else. I'll reopen for that. It is possible we could let |
(Compare #20660.) |
Change https://go.dev/cl/553157 mentions this issue: |
What version of Go are you using (
go version
)?Playground 1.21: https://go.dev/play/p/-NzVmrPm-ln
Does this issue reproduce with the latest release?
Yes: https://go.dev/play/p/-NzVmrPm-ln?v=gotip
What operating system and processor architecture are you using (
go env
)?N/A
What did you do?
(Code based on this from @rsc)
What did you expect to see?
One element deleted from the map: the one where DeleteFunc's predicate returns true (v == 7).
What did you see instead?
No elements are deleted from the map.
However, if I replace
m[math.NaN()] = i
withm[float64(i)] = i
, so that the map has all distinct non-NaN keys, it works.The text was updated successfully, but these errors were encountered: