1
0
mirror of https://github.com/golang/go synced 2024-11-23 04:40:09 -07:00
go/doc
Robert Griesemer 2d9378c7f6 spec: document existing expression switch restrictions
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>
2015-07-30 23:11:20 +00:00
..
articles doc/articles/wiki: remove generated final-test.go after test 2015-06-17 03:11:01 +00:00
codewalk doc: fix typo in sharemem codewalk 2014-05-21 14:34:20 -07:00
devel all: fix misprints in comments 2015-06-11 14:18:57 +00:00
gopher all: link to https for golang subdomains too 2015-07-12 04:42:40 +00:00
play doc/play: revise peano.go comment again. 2014-12-12 01:40:04 +00:00
progs doc/progs: disable cgo tests that use C.Stdout on Solaris 2015-05-06 11:38:22 +00:00
asm.html doc: mention the ppc64(le) ports in release notes 2015-07-23 02:11:48 +00:00
cmd.html all: use golang.org/x/... import paths 2014-11-10 09:15:57 +11:00
code.html doc: Added link to 'go help gopath' 2015-01-05 21:24:39 +00:00
contrib.html doc: suggest security@golang.org for reporting security issues 2015-06-26 09:53:36 +00:00
contribute.html doc: mention moderation delay in contributing docs 2015-06-19 21:01:48 +00:00
debugging_with_gdb.html build: adjustments for move from src/pkg to src 2014-09-08 00:06:45 -04:00
docs.html doc: drop scheme from links that are known to support HTTPS 2014-07-25 10:28:39 +10:00
effective_go.html doc: remove mention of default GOMAXPROCS(1) in Effective Go 2015-07-21 02:45:44 +00:00
gccgo_contribute.html doc: update gccgo docs for move of gofrontend to git 2015-06-19 01:03:21 +00:00
gccgo_install.html all: link to https instead of http 2015-07-11 14:36:33 +00:00
go1.1.html all: fix misprints in comments 2015-06-11 14:18:57 +00:00
go1.2.html doc: drop scheme from links that are known to support HTTPS 2014-07-25 10:28:39 +10:00
go1.3.html [release-branch.go1.4] doc: scrub references to code.google.com 2014-12-12 14:00:48 +11:00
go1.4.html doc/go1.4.html: fix typo 2015-03-24 18:17:49 +00:00
go1.5.html doc: in go1.5.html fix claim about linking for ppc64(le)? 2015-07-30 22:54:49 +00:00
go1.html doc: link directly to https://golang.org/dl/ 2014-09-12 09:15:58 +10:00
go1compat.html doc: add a clause about embedded methods to go1compat 2015-07-22 01:25:32 +00:00
go_faq.html doc: remove non-answer from FAQ 2015-07-29 23:01:10 +00:00
go_mem.html doc/go_mem.html: correct the channel example 2015-03-16 21:43:31 +00:00
go_spec.html spec: document existing expression switch restrictions 2015-07-30 23:11:20 +00:00
go-logo-black.png
go-logo-blue.png
go-logo-white.png
help.html [release-branch.go1.4] doc: scrub references to code.google.com 2014-12-12 14:00:48 +11:00
ie.css
install-source.html doc: add line break in install-source.html 2015-07-22 17:40:47 +00:00
install.html runtime, syscall: use SYSCALL instruction on FreeBSD. 2015-01-18 23:51:50 +00:00
root.html doc: drop scheme from links that are known to support HTTPS 2014-07-25 10:28:39 +10:00
share.png
tos.html doc: drop scheme from links that are known to support HTTPS 2014-07-25 10:28:39 +10:00