-
Notifications
You must be signed in to change notification settings - Fork 18k
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: comparable does not match each comparable type #51392
Comments
Biesction points to 163da6feb525a98dab5c1f01d81b2c705ead51ea as the bad commit, introduced in CL 387055. |
The reason for this is that Tag contains fullTag, which is an interface. This is discussed in more detail in #51257 (comment) This is a confusing UX, particularly when the interface is buried deep inside the type. Here the interface is only one level deep, but one can imagine how confusing it could be if the interface were inside several layers of nested structs. IMO this warrants reconsideration. |
Please correct me if I'm wrong. The specs defines the same rules for map keys as for stuff that implements |
To clarify: no, map keys treat all interfaces as comparable, whereas the |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
With the latest revision on
master
(a064a4f29a97a4fc7398d1ac9d7c53c5ba0bc646
).What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
language.Tag
as Map keylanguage.Tag
as comparable generic parameterThe following code
What did you expect to see?
language.Tag
as Map key: Is accepted by the compiler.language.Tag
as comparable generic parameter: Is accepted by the compiler.What did you see instead?
language.Tag
as Map key: Is accepted by the compiler.language.Tag
as comparable generic parameter: Compiler refuses compiling withThe text was updated successfully, but these errors were encountered: