A switch statement without a tag requires case values to be bools, but
the parser does not enforce that, so AST-walking code needs to take
care.
Change-Id: I7d9abbb0324314e02a37813c2d2f6adb0d6af5e7
Reviewed-on: https://go-review.googlesource.com/107375
Reviewed-by: Rob Pike <r@golang.org>
}
for _, expr := range cc.List {
v := f.pkg.types[expr].Value
- if v == nil || constant.BoolVal(v) {
+ if v == nil || v.Kind() != constant.Bool || constant.BoolVal(v) {
continue BodyLoopBool
}
}
// goto without label used to panic
goto
}
+
+func _() int {
+ // Empty switch tag with non-bool case value used to panic.
+ switch {
+ case 1:
+ println()
+ }
+ println()
+}