mirror of https://github.com/golang/go.git
spec: clarify that break/continue do not work across function boundaries
Also made it extra clear for goto statements (even though label scopes are already limited to the function defining a label). Fixes #8040. LGTM=r, rsc R=r, rsc, iant, ken CC=golang-codereviews https://golang.org/cl/99550043
This commit is contained in:
parent
ef25861222
commit
94849d5a78
|
|
@ -1,6 +1,6 @@
|
||||||
<!--{
|
<!--{
|
||||||
"Title": "The Go Programming Language Specification",
|
"Title": "The Go Programming Language Specification",
|
||||||
"Subtitle": "Version of May 22, 2014",
|
"Subtitle": "Version of May 28, 2014",
|
||||||
"Path": "/ref/spec"
|
"Path": "/ref/spec"
|
||||||
}-->
|
}-->
|
||||||
|
|
||||||
|
|
@ -5093,7 +5093,8 @@ func f(n int) (res int, err error) {
|
||||||
A "break" statement terminates execution of the innermost
|
A "break" statement terminates execution of the innermost
|
||||||
<a href="#For_statements">"for"</a>,
|
<a href="#For_statements">"for"</a>,
|
||||||
<a href="#Switch_statements">"switch"</a>, or
|
<a href="#Switch_statements">"switch"</a>, or
|
||||||
<a href="#Select_statements">"select"</a> statement.
|
<a href="#Select_statements">"select"</a> statement
|
||||||
|
within the same function.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre class="ebnf">
|
<pre class="ebnf">
|
||||||
|
|
@ -5127,6 +5128,7 @@ OuterLoop:
|
||||||
<p>
|
<p>
|
||||||
A "continue" statement begins the next iteration of the
|
A "continue" statement begins the next iteration of the
|
||||||
innermost <a href="#For_statements">"for" loop</a> at its post statement.
|
innermost <a href="#For_statements">"for" loop</a> at its post statement.
|
||||||
|
The "for" loop must be within the same function.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre class="ebnf">
|
<pre class="ebnf">
|
||||||
|
|
@ -5154,7 +5156,8 @@ RowLoop:
|
||||||
<h3 id="Goto_statements">Goto statements</h3>
|
<h3 id="Goto_statements">Goto statements</h3>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
A "goto" statement transfers control to the statement with the corresponding label.
|
A "goto" statement transfers control to the statement with the corresponding label
|
||||||
|
within the same function.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre class="ebnf">
|
<pre class="ebnf">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue