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

encoding/gob: misleading error message for maps with NaN keys #24075

Closed
bcmills opened this issue Feb 23, 2018 · 1 comment
Closed

encoding/gob: misleading error message for maps with NaN keys #24075

bcmills opened this issue Feb 23, 2018 · 1 comment
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@bcmills
Copy link
Contributor

bcmills commented Feb 23, 2018

The encoding/gob package emits an erroneous error message when attempting to encode a map containing irreflexive keys (such as math.NaN()):
https://play.golang.org/p/QgRVchmloT6

The error message it returns is gob: encodeReflectValue: nil element, but encodeReflectValue is not part of the exported or documented API, and there are no nil elements involved.

Ideally, encoding/gob should correctly handle maps with irreflexive keys. That would likely require either a fix for #11104, or a change to map lookups to use representation equivalence instead of == (per #20660 (comment)).

If it isn't feasible for gob to handle irreflexive map keys, that restriction should be documented in the gob package, and the errors that gob methods return should describe the correct problem.

This issue parallels #14427.

@gopherbot
Copy link

Change https://golang.org/cl/338609 mentions this issue: encoding/gob: marshal maps using reflect.Value.MapRange

@bcmills bcmills modified the milestones: Unplanned, Go1.18 Aug 5, 2021
@golang golang locked and limited conversation to collaborators Sep 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants