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
8c85e23 caused a regression where duplicate cases fail to be detected in a switch.
package main
funcmain() {
varaintswitcha {
case0,1:
case0:
}
}
On Go1.7, the above program fails:
./main.go:13: duplicate case 0 in switch
previous case at ./main.go:12
On Go1.8dev, the above program, unexpectedly succeeds.
I understand that this is not a language guarantee:
Implementation restriction: A compiler may disallow multiple case expressions evaluating to the same constant. For instance, the current compilers disallow duplicate integer, floating point, or string constants in case expressions.
However, we should be consistent with how it is done. The following snippet is rejected on both Go1.7 and Go1.8dev:
$ 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
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: