1
0
mirror of https://github.com/golang/go synced 2024-09-25 01:20:13 -06:00
Commit Graph

552 Commits

Author SHA1 Message Date
Brad Fitzpatrick
e963510330 spec: remove an unnecessary semicolon from code example
Change-Id: Ie4c92da0e3cbb97d3d7e03c7d15196c34f58a2cd
Reviewed-on: https://go-review.googlesource.com/42613
Reviewed-by: Robert Griesemer <gri@golang.org>
2017-05-04 02:46:51 +00:00
Robert Griesemer
50f67add81 spec: clarify admissible argument types for print, println
Fixes #19885.

Change-Id: I55420aace1b0f714df2d6460d2d1595f6863dd06
Reviewed-on: https://go-review.googlesource.com/42023
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2017-04-28 16:37:31 +00:00
Robert Griesemer
94b6011c78 spec: clarify use of fused-floating point operations
Added a paragraph and examples explaining when an implementation
may use fused floating-point operations (such as FMA) and how to
prevent operation fusion.

For #17895.

Change-Id: I64c9559fc1097e597525caca420cfa7032d67014
Reviewed-on: https://go-review.googlesource.com/40391
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2017-04-17 21:56:51 +00:00
Robert Griesemer
b0e5a0c93c spec: clarify size hint for make of maps
For #19903.

Change-Id: Ib28d08d45bfad653bcc1446f160b7b4a485529af
Reviewed-on: https://go-review.googlesource.com/40393
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2017-04-13 16:15:45 +00:00
Robert Griesemer
369d1083a7 spec: for non-constant map keys, add reference to evaluation order section
The section on map literals mentions constant map keys but doesn't say
what happens for equal non-constant map keys - that is covered in the
section on evaluation order. Added respective link for clarity.

Fixes #19689.

Change-Id: If9a5368ba02e8250d4bb0a1d60d0de26a1f37bbb
Reviewed-on: https://go-review.googlesource.com/38598
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-03-24 18:51:10 +00:00
Robert Griesemer
26e726c309 spec: remove superfluous terms "delimiter" and "special tokens"
The (original) section on "Operators and Delimiters" introduced
superfluous terminology ("delimiter", "special token") which
didn't matter and was used inconsistently.

Removed any mention of "delimiter" or "special token" and now
simply group the special character tokens into "operators"
(clearly defined via links), and "punctuation" (everything else).

Fixes #19450.

Change-Id: Ife31b24b95167ace096f93ed180b7eae41c66808
Reviewed-on: https://go-review.googlesource.com/38073
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Rob Pike <r@golang.org>
2017-03-13 18:02:57 +00:00
Robert Griesemer
866f63e84e spec: refer to "not defined type" rather than "unnamed type" in conversions
We missed this in https://golang.org/cl/36213.
Thanks to Chris Hines for pointing it out.

For #18130.

Change-Id: I6279ab19966c4391c4b4458b21fd2527d3f949dd
Reviewed-on: https://go-review.googlesource.com/36691
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-02-10 01:23:13 +00:00
Robert Griesemer
e62aab1274 spec: clarify alignment of arrays
Fixes #18950.

Change-Id: I9f94748f36a896bcadc96f0642eb1f3bff387950
Reviewed-on: https://go-review.googlesource.com/36481
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-02-07 16:28:06 +00:00
Robert Griesemer
c0bd4f33cc spec: pick up a few corrections missed in prior commit
This CL picks up a couple of minor fixes that were present
in https://go-review.googlesource.com/#/c/36213/6..5 but
accidentally got dropped in https://go-review.googlesource.com/#/c/36213/
because I submitted from the wrong client.

Change-Id: I3ad0d20457152ea9a116cbb65a23eb0dc3a8525e
Reviewed-on: https://go-review.googlesource.com/36471
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-02-07 00:03:00 +00:00
Robert Griesemer
56c9b51b93 spec: introduce alias declarations and type definitions
To avoid confusion caused by the term "named type" (which now just
means a type with a name, but formerly meant a type declared with
a non-alias type declaration), a type declaration now comes in two
forms: alias declarations and type definitions. Both declare a type
name, but type definitions also define new types.

Replace the use of "named type" with "defined type" elsewhere in
the spec.

For #18130.

Change-Id: I49f5ddacefce90354eb65ee5fbf10ba737221995
Reviewed-on: https://go-review.googlesource.com/36213
Reviewed-by: Rob Pike <r@golang.org>
2017-02-06 23:51:47 +00:00
Robert Griesemer
f8b4123613 [dev.typealias] spec: use term 'embedded field' rather than 'anonymous field'
First steps towards defining type aliases in the spec.
This is a nomenclature clarification, not a language change.

The spec used all three terms 'embedded type', 'anonymous field',
and 'embedded field'. Users where using the terms inconsistently.

The notion of an 'anonymous' field was always misleading since they
always had a de-facto name. With type aliases that name becomes even
more important because we may have different names for the same type.

Use the term 'embedded field' consistently and remove competing
terminology.

For #18130.

Change-Id: I2083bbc85788cab0b2e2cb1ff58b2f979491f001
Reviewed-on: https://go-review.googlesource.com/35108
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2017-01-31 17:12:17 +00:00
Robert Griesemer
b01f612a69 spec: add subtitles to section on "for" statements
This matches what we already do for switch statements and makes
this large section more visibly organized. No other changes besides
introducing the titles.

Fixes #4486.

Change-Id: I73f274e4fdd27c6cfeaed79090b4553e57a9c479
Reviewed-on: https://go-review.googlesource.com/33410
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-11-18 20:26:11 +00:00
Robert Griesemer
0eb26fa8ba spec: remove => (alias) operator from Operators and Delimiters section
(Revert of https://go-review.googlesource.com/#/c/32310/)

For #16339.
Fixes #17975.

Change-Id: I36062703c423a81ea1c5b00f4429a4faf00b3782
Reviewed-on: https://go-review.googlesource.com/33365
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-11-18 17:45:45 +00:00
Robert Griesemer
120cf676ca spec: clarify type elision rules for composite literals
- organize examples better
- add an example illustrating behavior if element type is a named pointer type
- both compilers and go/types (per https://go-review.googlesource.com/33358)
  follow this now

See the issue for detailed discussion.

Fixes #17954.

Change-Id: I8d90507ff2347d9493813f75b73233819880d2b4
Reviewed-on: https://go-review.googlesource.com/33361
Reviewed-by: Rob Pike <r@golang.org>
2016-11-18 17:25:07 +00:00
Robert Griesemer
87f4e36ce7 Revert "spec: add new language for alias declarations"
This reverts commit aff37662d1.

Reason: Decision to back out current alias implementation.
https://github.com/golang/go/issues/16339#issuecomment-258527920

Fixes #16339.
Fixes #17746.
Fixes #17784.

Change-Id: I5737b830d7f6fb79cf36f26403b4ad8533ba1dfe
Reviewed-on: https://go-review.googlesource.com/32813
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-11-04 19:57:23 +00:00
Robert Griesemer
7fd6b925e3 spec: update operator and delimiter section
Follow-up on https://go-review.googlesource.com/30601.

Change-Id: I51b603a6c4877b571e83cd7c4e78a8988cc831ca
Reviewed-on: https://go-review.googlesource.com/32310
Reviewed-by: Rob Pike <r@golang.org>
2016-10-28 17:05:48 +00:00
Robert Griesemer
aff37662d1 spec: add new language for alias declarations
For #16339.

Change-Id: I7d912ea634bbfacfc0217f97dccb270fde06f16b
Reviewed-on: https://go-review.googlesource.com/30601
Reviewed-by: Russ Cox <rsc@golang.org>
2016-10-27 17:48:02 +00:00
Robert Griesemer
023bb034e9 spec: slightly more realistic example for type assertions
For #17428.

Change-Id: Ia902b50cf0c40e3c2167fb573a39d328331c38c7
Reviewed-on: https://go-review.googlesource.com/31449
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-19 17:16:55 +00:00
Robert Griesemer
8fbfdad281 spec: require 16 bit minimum exponent in constants rather than 32
A 16bit binary exponent permits a constant range covering roughly the range
from 7e-9865 to 7e9863 which is more than enough for any practical and
hypothetical constant arithmetic.

Furthermore, until recently cmd/compile could not handle very large exponents
correctly anyway; i.e., the chance that any real programs (but for tests that
explore corner cases) are affected are close to zero.

Finally, restricting the minimum supported range significantly reduces the
implementation complexity in an area that hardly matters in reality for new
or alternative spec-compliant implementations that don't or cannot rely on
pre-existing arbitratry precision arithmetic packages that support a 32bit
exponent range.

This is technically a language change but for the reasons mentioned above
this is unlikely to affect any real programs, and certainly not programs
compiled with the gc or gccgo compilers as they currently support up to
32bit exponents.

Fixes #13572.

Change-Id: I970f919c57fc82c0175844364cf48ea335f17d39
Reviewed-on: https://go-review.googlesource.com/17711
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-10-18 22:36:50 +00:00
Robert Griesemer
5567b87891 spec: fix examples for predeclared function complex
Fixes #17398.

Change-Id: Iac7899031c1bfbadc4f84e5b374eaf1f01dff8c8
Reviewed-on: https://go-review.googlesource.com/31190
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-10-14 19:58:27 +00:00
Robert Griesemer
a016ecfdcb spec: clarify acceptable indices in array/slice composite literals
This simply documents the status quo accepted by cmd/compile, gccgo,
and go/types. The new language matches the language used for indices
of index expressions for arrays and slices.

Fixes #16679.

Change-Id: I65447889fbda9d222f2a9e6c10334d1b38c555f0
Reviewed-on: https://go-review.googlesource.com/30474
Reviewed-by: Rob Pike <r@golang.org>
2016-10-06 20:37:39 +00:00
Robert Griesemer
5c7a005266 spec: ignore struct tags when converting structs
This is a backwards-compatible language change.

Per the proposal (#16085), the rules for conversions are relaxed
such that struct tags in any of the structs involved in the conversion
are ignored (recursively).

Because this is loosening the existing rules, code that compiled so
far will continue to compile.

For #16085.
Fixes #6858.

Change-Id: I0feef651582db5f23046a2331fc3f179ae577c45
Reviewed-on: https://go-review.googlesource.com/24190
Reviewed-by: Russ Cox <rsc@golang.org>
2016-10-04 17:07:37 +00:00
Robert Griesemer
f8555ea6fd spec: update language on type switches to match implementations
See the issue below for details.

Fixes #16794.

Change-Id: I7e338089fd80ddcb634fa80bfc658dee2772361c
Reviewed-on: https://go-review.googlesource.com/27356
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-09-01 04:37:16 +00:00
Robert Griesemer
a656390b69 spec: clarify text on init functions
For #16874.

Change-Id: I2e13f582297606e506d805755a6cfc1f3d4306a2
Reviewed-on: https://go-review.googlesource.com/27817
Reviewed-by: Rob Pike <r@golang.org>
2016-08-26 06:10:32 +00:00
Robert Griesemer
507051d694 spec: complete list of special comma-ok forms
The enumerations didn't include the syntactic form where the lhs is
full variable declaration with type specification, as in:

var x, ok T = ...

Fixes #15782.

Change-Id: I0f7bafc37dc9dcf62cdb0894a0d157074ccd4b3e
Reviewed-on: https://go-review.googlesource.com/27670
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-08-24 21:24:28 +00:00
Robert Griesemer
3b967be421 spec: undo spec date change introduced by prior commit
I accidentally included a modified spec in
https://go-review.googlesource.com/27290 .
Remove that change.

Change-Id: Icb62fe829072860e9eb74865d21e06f30efcfd26
Reviewed-on: https://go-review.googlesource.com/27357
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-08-18 20:24:45 +00:00
Robert Griesemer
fd8028dec9 go/types: fix scope extents for range and type switch variables
The changes match the existing compilers, and assume an adjusted
spec (per issue #16794).

Fixes #15686.

Change-Id: I72677ce75888c41a8f3c2963117a2f2d5501c42b
Reviewed-on: https://go-review.googlesource.com/27290
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-08-18 20:07:05 +00:00
Robert Griesemer
3d81d4adc9 spec: document that duplicate types are invalid in type switches
Both compilers and also go/types don't permit duplicate types in
type switches; i.e., this spec change is documenting a status quo
that has existed for some time.

Furthermore, duplicate nils are not accepted by gccgo or go/types;
and more recently started causing a compiler error in gc. Permitting
them is inconsistent with the existing status quo.

Rather than making it an implementation restriction (as we have for
expression switches), this is a hard requirement since it was enforced
from the beginning (except for duplicate nils); it is also a well
specified requirement that does not pose a significant burden for
an implementation.

Fixes #15896.

Change-Id: If12db5bafa87598b323ea84418cb05421e657dd8
Reviewed-on: https://go-review.googlesource.com/23584
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-05-31 23:53:43 +00:00
Robert Griesemer
0436a89a2c spec: be more explicit about equivalence of empty string and absent field tags
Note that the spec already makes that point with a comment in the very first
example for struct field tags. This change is simply stating this explicitly
in the actual spec prose.

- gccgo and go/types already follow this rule
- the current reflect package API doesn't distinguish between absent tags
  and empty tags (i.e., there is no discoverable difference)

Fixes #15412.

Change-Id: I92f9c283064137b4c8651630cee0343720717a02
Reviewed-on: https://go-review.googlesource.com/22391
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-04-25 19:21:40 +00:00
Robert Griesemer
5213cd7000 spec: fix incorrect comment in shift example
- adjusted example code
- fixed comments

Fixes #14785.

Change-Id: Ia757dc93b0a69b8408559885ece7f3685a37daaa
Reviewed-on: https://go-review.googlesource.com/22353
Reviewed-by: Rob Pike <r@golang.org>
2016-04-21 20:58:54 +00:00
Robert Griesemer
b5ddbb90bf spec: refine rules about terminating statements
Per a suggestion from mdempsky.

Both gc and gccgo consider a statement list as terminating if the
last _non_empty_ statement is terminating; i.e., trailing semis are
ok. Only gotype followed the current stricter rule in the spec.

This change adjusts the spec to match gc and gccgo behavior. In
support of this change, the spec has a matching rule for fallthrough,
which in valid positions may be followed by trailing semis as well.

For details and examples, see the issue below.

Fixes #14422.

Change-Id: Ie17c282e216fc40ecb54623445c17be111e17ade
Reviewed-on: https://go-review.googlesource.com/19981
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-04-19 17:34:12 +00:00
Robert Griesemer
5583e8a421 spec: fix EBNF for slice syntax
The () parentheses grouped wrongly. Removed them completely in
favor of separate 2- and 3-index slice alternatives which is
clearer.

Fixes #14477.

Change-Id: I0b7521ac912130d9ea8740b8793b3b88e2609418
Reviewed-on: https://go-review.googlesource.com/19853
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-02-23 19:18:25 +00:00
Robert Griesemer
212bdd95e0 spec: New year, new spec update (to refer to Unicode 8.0).
Slightly rephrased sentence to emphasize the contents of the
Unicode categories w/o repeating the full category name each
time.

Fixes #13414.

Change-Id: Icd32ff1547fa81e866c5937a631c3344bb6087c6
Reviewed-on: https://go-review.googlesource.com/18265
Reviewed-by: Rob Pike <r@golang.org>
2016-01-05 22:39:26 +00:00
Shenghou Ma
ca9876dd2f doc: fix typo
Fixes #13780.

Change-Id: I629e2ba79b74d693e04c3747812c9a686cae5335
Reviewed-on: https://go-review.googlesource.com/18218
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-01-01 05:00:12 +00:00
Robert Griesemer
57c81ef257 spec: be clearer about which parameter section can be variadic
Fixes #13595.

Change-Id: I870ddc97ea25b7f6f7a1bb1a78e5e4874fba1ddc
Reviewed-on: https://go-review.googlesource.com/17871
Reviewed-by: Rob Pike <r@golang.org>
2015-12-15 21:58:04 +00:00
Robert Griesemer
7305b55e98 spec: clarify examples for struct field tags
Fixes #13420.

Change-Id: Id64ebd0527881450fdaffbb66d8b1831a6b7c43c
Reviewed-on: https://go-review.googlesource.com/17263
Reviewed-by: Rob Pike <r@golang.org>
2015-11-30 22:24:13 +00:00
Robert Griesemer
09e900eb33 spec: clarify that iota is incremented even if not used in a const spec
Slightly modified an example.

Fixes #13371.

Change-Id: I25d260d4200086a0ef9725950132b760657610c5
Reviewed-on: https://go-review.googlesource.com/17209
Reviewed-by: Rob Pike <r@golang.org>
2015-11-26 17:10:22 +00:00
Matthew Dempsky
ff85f86877 spec: remove "untyped bool" oxymorons
The proper term is "untyped boolean".

Change-Id: Id871164190a03c64a8a8987b1ad5d8653a21d96e
Reviewed-on: https://go-review.googlesource.com/16135
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-10-20 22:08:17 +00:00
Robert Griesemer
55ecda4ffd spec: clarify numeric conversions where IEEE-754 produces -0.0
The spec defines precise numeric constants which do not overflow.
Consequently, +/-Inf and NaN values were excluded. The case was not
clear for -0.0 but they are mostly of interest to determine the sign
of infinities which don't exist.

That said, the conversion rules explicitly say that T(x) (for a numeric
x and floating-point type T) is the value after rounding per IEEE-754.
The result is constant if x is constant. Rounding per IEEE-754 can
produce a -0.0 which we cannot represent as a constant.

Thus, the spec is inconsistent. Attempt to fix the inconsistency by
adjusting the rounding rule rather than letting -0.0 into the language.

For more details, see the issue below.

Open to discussion.

Fixes #12576.

Change-Id: Ibe3c676372ab16d9229f1f9daaf316f761e074ee
Reviewed-on: https://go-review.googlesource.com/14727
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-10-20 18:16:57 +00:00
Robert Griesemer
c720875b76 spec: minor adjustment of prose in composite literal section
The prose discussing composite literals referred to the composite
literal type with 'LiteralType', denoting the literal type's EBNF
production explicitly. Changed 'LiteralType' to 'literal type' to
remove the literal (no pun intended) connection and instead mean
the underlying type. Seems a simpler and more readable change
than referring to the underlying type everywhere explicitly.

Fixes #12717.

Change-Id: I225df95f9ece2664b19068525ea8bda5ca05a44a
Reviewed-on: https://go-review.googlesource.com/14851
Reviewed-by: Rob Pike <r@golang.org>
2015-09-23 21:26:10 +00:00
Robert Griesemer
3b0224282c spec: fix composite literal syntax to match prose
Fixes #12578.

Change-Id: I257d70a67609463e24936bc1739285da154be2fe
Reviewed-on: https://go-review.googlesource.com/14531
Reviewed-by: Rob Pike <r@golang.org>
2015-09-12 00:45:55 +00:00
Robert Griesemer
98aa82287f spec: clarify semantics of built-in functions 'complex', 'real', and 'imag'
For #11669, #11540, #11945, #11946, #11947.

Change-Id: Ifb0053c498cee9f3473c396f9338d82bd856c110
Reviewed-on: https://go-review.googlesource.com/12860
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2015-08-05 21:09:49 +00:00
Robert Griesemer
3dd3ab41ac spec: better organization of arithmetic operator section
First step towards cleaning up the operator section - no language
changes. Specifically:

- Grouped arithmetic operations by types (integer, floating-point,
  string), with corresponding h4 headings.

- Changed Operator precedence title from h3 to h4.

- Moved Integer Overflow section after integer operations and changed
  its title from h3 to h4.

This puts things that belong together closer. No heading id's were
lost (in case of references from outside the spec).

Change-Id: I6b349ba8d86a6ae29b596beb297cc45c81e69399
Reviewed-on: https://go-review.googlesource.com/13143
Reviewed-by: Rob Pike <r@golang.org>
2015-08-05 17:05:07 +00:00
Robert Griesemer
05614bfcfa spec: fix inconsistency of visibility rules for method names
Inconsistency identified by Anmol Sethi (anmol@aubble.com).

Fixes #10341.

Change-Id: I1a1f5b22aad29b56280f81026feaa37a61b3e0a9
Reviewed-on: https://go-review.googlesource.com/13132
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-08-05 17:03:36 +00:00
Robert Griesemer
85789daac3 spec: clarify that short variable declarations can redeclare parameters
Fixes #9837.

Change-Id: Ia513c7e5db221eee8e3ab0affa6d3688d2099fd9
Reviewed-on: https://go-review.googlesource.com/13130
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-08-05 17:01:05 +00:00
Robert Griesemer
87c8707e6f spec: clarify sentence about non-constant shifts
Fixes #10514.

Change-Id: Iae95a304d3ebb1ed82567aa234e05dc434db984f
Reviewed-on: https://go-review.googlesource.com/13098
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-08-05 17:00:11 +00:00
Robert Griesemer
02d74485e4 spec: fixed various example code snippets
Per suggestions by Peter Olsen (https://github.com/pto).

Fixes #11964.

Change-Id: Iae261ac14f75abf848f5601f59d7fe6e95b6805a
Reviewed-on: https://go-review.googlesource.com/13006
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-07-31 20:38:44 +00:00
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
Robert Griesemer
37a097519f spec: be precise about rune/string literals and comments
See #10248 for details.

Fixes #10248.

Change-Id: I373545b2dca5d1da1c7149eb0a8f6c6dd8071a4c
Reviewed-on: https://go-review.googlesource.com/10503
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2015-07-23 17:34:17 +00:00
Paolo Martini
3549178e55 doc: fix typo
The document `doc/go_spec.html` uses "preceeding" instead of the word
"preceding" in one place.

Fixed another occurrence in `src/go/types/typexpr.go`.

Change-Id: Ic67f62026b5c9d002c5c5632299f14ecac8b02ae
Reviewed-on: https://go-review.googlesource.com/12354
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-07-17 22:33:51 +00:00