From: griesemer Date: Wed, 18 Oct 2017 22:31:42 +0000 (-0700) Subject: spec: clarify that each block has its own version of iota X-Git-Tag: go1.10beta1~660 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=52dd39965e78260145091226490ee5510ea34ced;p=gostls13.git 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 Reviewed-by: Matthew Dempsky Reviewed-by: Ian Lance Taylor --- diff --git a/doc/go_spec.html b/doc/go_spec.html index fd3830dcf0..3cb221ce6c 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -1,6 +1,6 @@ @@ -1866,8 +1866,8 @@ const (

Within a constant declaration, the predeclared identifier iota represents successive untyped integer -constants. It is reset to 0 whenever the reserved word const -appears in the source and increments after each ConstSpec. +constants. Its value is the index of the respective ConstSpec +in that constant declaration, starting at zero. It can be used to construct a set of related constants: