go/types: int overflow in switch expression
dvyukov opened this issue · comments
Dmitry Vyukov commented
gotype successfully compiles the following program:
package a
func f() {
switch 9223372036854775808 {
}
}
gc rejects it with:
go.go:3: constant 9223372036854775808 overflows int
gc seems to be right.
on commit af81789
Dmitry Vyukov commented
The same happens in switch cases as well:
package a
func f() {
switch 9223372036854775808 {
case 9223372036854775808:
}
}
Robert Griesemer commented
The switch statement is actually underspecified in this respect. It does not say that the switch expression has to fit into a basic type. So technically, I believe gotype is correct. That said, I think the spec needs to be clarified as the current situation is not tenable in general. Leaving as go/types bug.
GopherBot commented
CL https://golang.org/cl/12713 mentions this issue.