From: Robert Griesemer Date: Wed, 5 Oct 2016 22:59:09 +0000 (-0700) Subject: spec: clarify acceptable indices in array/slice composite literals X-Git-Tag: go1.8beta1~985 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=a016ecfdcbc266f45f33350238777fba9a391b8d;p=gostls13.git spec: clarify acceptable indices in array/slice composite literals This simply documents the status quo accepted by cmd/compile, gccgo, and go/types. The new language matches the language used for indices of index expressions for arrays and slices. Fixes #16679. Change-Id: I65447889fbda9d222f2a9e6c10334d1b38c555f0 Reviewed-on: https://go-review.googlesource.com/30474 Reviewed-by: Rob Pike --- diff --git a/doc/go_spec.html b/doc/go_spec.html index 6e07c945e1..5f0a16c0ff 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -1,6 +1,6 @@ @@ -2286,8 +2286,10 @@ For array and slice literals the following rules apply:
  • Each element has an associated integer index marking its position in the array.
  • -
  • An element with a key uses the key as its index; the - key must be a constant integer expression. +
  • An element with a key uses the key as its index. The + key must be a non-negative constant representable by + a value of type int; and if it is typed + it must be of integer type.
  • An element without a key uses the previous element's index plus one. If the first element has no key, its index is zero.