-
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
cmd/compile: identical generic types compare unequal #49241
Comments
Can you whittle down (remove everything that's not needed to re-produce the problem) in the real code and send that CL? Then we can cherry-pick and investigate. |
Hm, the switch is failing because the itab of the incoming interface doesn't match the itab returned by the calls.
That's not good. We require that itabs be unique, so that we can type switch using equality of itabs. |
The linker is not deduplicating the itabs because their
I'm not sure yet why the types aren't being deduplicated. They have the same name, and they look identical except for the |
Change https://golang.org/cl/360134 mentions this issue: |
I've made a small repro that I think is the same underlying cause. |
@rogpeppe prepared a self-contained testscript for this issue in #49245.
|
(Note: this is my first attempt at writing generic code, the chances I am just wrong are high.)
crypto/elliptic has a few functions like
P256() Curve
andP384() Curve
that return a singleton implementation of that curve. The singleton is part of the contract, because applications are expected to check what curve is in use by comparing it against the return value ofelliptic.P384()
.In CL 360015 I experimented with turning the concrete implementation of those singletons into a pointer to a generic type. (Feedback on the use of generics welcome!)
Unexpectedly, this led to a test failure that stems from this switch not matching the singletons anymore.
go/src/crypto/x509/x509.go
Lines 508 to 521 in 2ebe77a
I tried reproducing it with a contained example on the playground, but things worked as expected, so I am not sure what is going on. https://go2goplay.golang.org/p/9jnZvqnPDrh
/cc @griesemer
The text was updated successfully, but these errors were encountered: