reflect: ArrayOf bugs: type identity, hashability #22605
Labels
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
release-blocker
Milestone
Filing a bug, per suggestion on mailing list: https://groups.google.com/d/topic/golang-nuts/LwKSTzS72gg/discussion
What version of Go are you using (
go version
)?go version go1.8.3 darwin/amd64
Does this issue reproduce with the latest release?
Yes, I believe so. I can repro on the Go Playground, which is using Go 1.9.
What operating system and processor architecture are you using (
go env
)?Macbook Pro (darwin/amd64).
What did you do?
Type Identity
Created a type using
reflect.ArrayOf
. Compared the resultingreflect.Type
instance to another type, an identical type, that was not acquired through the use ofreflect.ArrayOf
.Hashability
Created a type using
reflect.ArrayOf
. Created a value of this type usingreflect.New
. Attempted to use the array value as a key in a map.https://play.golang.org/p/Qu0irn2rCF
What did you expect to see?
Type Identity
Per package documentation of the reflect package and language spec describing type identity (in particular, regarding array types), I expected the comparison result to be true.
Hashability
Per the language spec, allowing use of arrays as map keys, I expected using a value of a type created via
reflect.ArrayOf
to be successfully used as a map key, without panic.What did you see instead?
Type Identity
The comparison result was false.
Hashability
Attempting to use the constructed array value as a map key resulted in a panic:
The text was updated successfully, but these errors were encountered: