-
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: regression in type switch deduplication #17517
Comments
Caused by 8c85e23. Must be fixed for Go 1.8. /cc @josharian @mdempsky |
Interestingly type switches catch the duplicates but the expression switches package main
func main() {
var a int
switch a {
case 1, 0:
case 0:
}
var s interface{} = "hello"
switch s.(type) {
case string:
case int, string:
}
} $ go run main.go
./main.go:13: duplicate case string in type switch
previous case at ./main.go:12
$ go version
go version devel +930ab0a Fri Oct 21 02:14:57 2016 +0000 darwin/amd64 so I think that can narrow the bug to the code for *exprSwitch |
I've mailed https://go-review.googlesource.com/31671 |
CL https://golang.org/cl/31671 mentions this issue. |
CL https://golang.org/cl/31716 mentions this issue. |
@odeke-em Thanks again for your help in root causing the issue! |
8c85e23 caused a regression where duplicate cases fail to be detected in a switch.
On Go1.7, the above program fails:
On Go1.8dev, the above program, unexpectedly succeeds.
I understand that this is not a language guarantee:
However, we should be consistent with how it is done. The following snippet is rejected on both Go1.7 and Go1.8dev:
/cc @josharian @mdempsky
The text was updated successfully, but these errors were encountered: