You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Slice, map, and function types are not comparable. However, as a special case, a slice, map, or function value may be compared to the predeclared identifier `.
Based on this, I would expect a switch expression on an array (for example) to not compile. Note that this following code indeed does not compile, which matches expectations.
But as the spec doesn't mention any difference between the "non-comparability" of type parameters, and other non-comparable types, I expected them to behave the same.
The text was updated successfully, but these errors were encountered:
[3]int is an array type, not a slice, and array types are comparable. I think this is working as intended, so I'm closing, but feel free to comment if I've misunderstood the issue.
Go version
1.22.0
Output of
go env
in your module/workspace:What did you do?
I ran this program with
go run .
What did you see happen?
It compiled, and output the following text:
What did you expect to see?
I expected a compilation error.
The spec states that:
Further it explains:
Based on this, I would expect a switch expression on an array (for example) to not compile. Note that this following code indeed does not compile, which matches expectations.
But as the spec doesn't mention any difference between the "non-comparability" of type parameters, and other non-comparable types, I expected them to behave the same.
The text was updated successfully, but these errors were encountered: