1
0
mirror of https://github.com/golang/go synced 2024-11-22 22:40:02 -07:00

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>
This commit is contained in:
Robert Griesemer 2016-02-26 15:52:13 -08:00
parent a39950ba66
commit b5ddbb90bf

View File

@ -1,6 +1,6 @@
<!--{
"Title": "The Go Programming Language Specification",
"Subtitle": "Version of February 23, 2016",
"Subtitle": "Version of April 19, 2016",
"Path": "/ref/spec"
}-->
@ -4257,7 +4257,7 @@ All other statements are not terminating.
<p>
A <a href="#Blocks">statement list</a> ends in a terminating statement if the list
is not empty and its final statement is terminating.
is not empty and its final non-empty statement is terminating.
</p>