Description
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.