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

reflect: ArrayOf bugs: type identity, hashability #22605

Closed
jhump opened this issue Nov 6, 2017 · 4 comments
Closed

reflect: ArrayOf bugs: type identity, hashability #22605

jhump opened this issue Nov 6, 2017 · 4 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker
Milestone

Comments

@jhump
Copy link

jhump commented Nov 6, 2017

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 resulting reflect.Type instance to another type, an identical type, that was not acquired through the use of reflect.ArrayOf.

Hashability
Created a type using reflect.ArrayOf. Created a value of this type using reflect.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:

runtime error: hash of unhashable type [8]int32
@bradfitz
Copy link
Contributor

bradfitz commented Nov 7, 2017

/cc @ianlancetaylor @crawshaw

@bradfitz bradfitz added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Nov 7, 2017
@bradfitz bradfitz changed the title reflect.ArrayOf bugs: type identity, hashability reflect: ArrayOf bugs: type identity, hashability Nov 7, 2017
@bradfitz bradfitz added this to the Go1.10 milestone Nov 7, 2017
@ianlancetaylor
Copy link
Contributor

When I run the test program on GNU/Linux it passes on amd64 but fails when I set GOARCH=386.

@ianlancetaylor
Copy link
Contributor

I think this is another variant of #17752.

@gopherbot
Copy link

Change https://golang.org/cl/76315 mentions this issue: cmd/compile: don't put Noalg types in typelinks

@golang golang locked and limited conversation to collaborators Nov 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker
Projects
None yet
Development

No branches or pull requests

4 participants