-
Notifications
You must be signed in to change notification settings - Fork 18k
runtime: map lookup of non-comparable value doesn't panic #23734
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
Comments
Oh, the issue is because of this short-circuit in mapaccess1:
If |
We could call |
That said, I'd expect hash lookups into nil and empty maps might be pretty common, so it'd be desirable to skip the hash operation if possible? The compiler could add another flag to maptype (like |
Same for delete package main
func main() {
var m = map[interface{}]int{}
var i interface{} = []int{}
delete(m, i)
} |
Change https://golang.org/cl/155918 mentions this issue: |
related issues: golang/go#23734, golang/go#11104 Update #3
https://play.golang.org/p/ZLieXU_3vuB
This program prints
0
:The Go spec says:
It seems unspecified what exactly "failure" means, but my interpretation is that using a non-comparable value like
k
above in the expressionm[k]
should constitute as "failure"./cc @griesemer @ianlancetaylor @randall77
The text was updated successfully, but these errors were encountered: