mirror of
https://github.com/golang/go
synced 2024-11-25 05:57:57 -07:00
spec: disallow unused labels
Also change labelled examples to use gofmt formatting. R=gri, r, jnml CC=golang-dev https://golang.org/cl/4287046
This commit is contained in:
parent
f192891786
commit
108564dabc
@ -1,5 +1,5 @@
|
|||||||
<!-- title The Go Programming Language Specification -->
|
<!-- title The Go Programming Language Specification -->
|
||||||
<!-- subtitle Version of March 11, 2011 -->
|
<!-- subtitle Version of March 15, 2011 -->
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
TODO
|
TODO
|
||||||
@ -1472,6 +1472,7 @@ declarations.
|
|||||||
Labels are declared by <a href="#Labeled_statements">labeled statements</a> and are
|
Labels are declared by <a href="#Labeled_statements">labeled statements</a> and are
|
||||||
used in the <code>break</code>, <code>continue</code>, and <code>goto</code>
|
used in the <code>break</code>, <code>continue</code>, and <code>goto</code>
|
||||||
statements (§<a href="#Break_statements">Break statements</a>, §<a href="#Continue_statements">Continue statements</a>, §<a href="#Goto_statements">Goto statements</a>).
|
statements (§<a href="#Break_statements">Break statements</a>, §<a href="#Continue_statements">Continue statements</a>, §<a href="#Goto_statements">Goto statements</a>).
|
||||||
|
It is illegal to define a label that is never used.
|
||||||
In contrast to other identifiers, labels are not block scoped and do
|
In contrast to other identifiers, labels are not block scoped and do
|
||||||
not conflict with identifiers that are not labels. The scope of a label
|
not conflict with identifiers that are not labels. The scope of a label
|
||||||
is the body of the function in which it is declared and excludes
|
is the body of the function in which it is declared and excludes
|
||||||
@ -4256,11 +4257,13 @@ terminates
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
L: for i < n {
|
L:
|
||||||
|
for i < n {
|
||||||
switch i {
|
switch i {
|
||||||
case 5: break L
|
case 5:
|
||||||
|
break L
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<h3 id="Continue_statements">Continue statements</h3>
|
<h3 id="Continue_statements">Continue statements</h3>
|
||||||
@ -4302,8 +4305,8 @@ instance, this example:
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
goto L // BAD
|
goto L // BAD
|
||||||
v := 3
|
v := 3
|
||||||
L:
|
L:
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user