mirror of
https://github.com/golang/go
synced 2024-11-23 04:40:09 -07:00
2d9378c7f6
The spec didn't specify several aspects of expression switches: - The switch expression is evaluated exactly once. - Switch expressions evaluating to an untyped value are converted to the respective default type before use. - An (untyped) nil value is not permitted as expression switch value. (We could permit it relatively easily, but gc doesn't, and disallowing it is in symmetry with the rules for var decls without explicit type and untyped initializer expressions.) - The comparison x == t between each case expression x and switch expression value t must be valid. - (Some) duplicate constant case expressions are not permitted. This change also clarifies the following issues: 4524: mult. equal int const switch case values should be illegal -> spec issue fixed 6398: switch w/ no value uses bool rather than untyped bool -> spec issue fixed 11578: allows duplicate switch cases -> go/types bug 11667: int overflow in switch expression -> go/types bug 11668: use of untyped nil in switch -> not a gc bug Fixes #4524. Fixes #6398. Fixes #11668. Change-Id: Iae4ab3e714575a5d11c92c9b8fbf027aa706b370 Reviewed-on: https://go-review.googlesource.com/12711 Reviewed-by: Russ Cox <rsc@golang.org> Reviewed-by: Rob Pike <r@golang.org> |
||
---|---|---|
.. | ||
articles | ||
codewalk | ||
devel | ||
gopher | ||
play | ||
progs | ||
asm.html | ||
cmd.html | ||
code.html | ||
contrib.html | ||
contribute.html | ||
debugging_with_gdb.html | ||
docs.html | ||
effective_go.html | ||
gccgo_contribute.html | ||
gccgo_install.html | ||
go1.1.html | ||
go1.2.html | ||
go1.3.html | ||
go1.4.html | ||
go1.5.html | ||
go1.html | ||
go1compat.html | ||
go_faq.html | ||
go_mem.html | ||
go_spec.html | ||
go-logo-black.png | ||
go-logo-blue.png | ||
go-logo-white.png | ||
help.html | ||
ie.css | ||
install-source.html | ||
install.html | ||
root.html | ||
share.png | ||
tos.html |