Skip to content

Commit 52dd399

Browse files
committed
spec: clarify that each block has its own version of iota
Issue #15550 is clearly an esoteric case but the spec was silent about it and we had diverging implementations. By making `iota` and index that is relative to the respective constant declaration, nested const declarations won't affect outer values of `iota`. cmd/compile and go/types already follow this semantics. Fixes #15550. Change-Id: If138189e3ea4373f8ba50ac6fb1d219b481f8698 Reviewed-on: https://go-review.googlesource.com/71750 Reviewed-by: Rob Pike <[email protected]> Reviewed-by: Matthew Dempsky <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 58d7231 commit 52dd399

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

doc/go_spec.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!--{
22
"Title": "The Go Programming Language Specification",
3-
"Subtitle": "Version of October 17, 2017",
3+
"Subtitle": "Version of October 18, 2017",
44
"Path": "/ref/spec"
55
}-->
66

@@ -1866,8 +1866,8 @@ <h3 id="Iota">Iota</h3>
18661866
<p>
18671867
Within a <a href="#Constant_declarations">constant declaration</a>, the predeclared identifier
18681868
<code>iota</code> represents successive untyped integer <a href="#Constants">
1869-
constants</a>. It is reset to 0 whenever the reserved word <code>const</code>
1870-
appears in the source and increments after each <a href="#ConstSpec">ConstSpec</a>.
1869+
constants</a>. Its value is the index of the respective <a href="#ConstSpec">ConstSpec</a>
1870+
in that constant declaration, starting at zero.
18711871
It can be used to construct a set of related constants:
18721872
</p>
18731873

0 commit comments

Comments
 (0)