aboutsummaryrefslogtreecommitdiff
path: root/doc/go_spec.html
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2022-11-21 16:02:20 -0800
committerGopher Robot <gobot@golang.org>2022-11-23 00:25:08 +0000
commit753ad5e1d59db9073abba07627723fa3267a52fd (patch)
tree24fb93f845aea8fb6e9543e89eb01db593dd7d2b /doc/go_spec.html
parent1fbfc2f6eba6cc88a8fb0ae8e83afe80553f65df (diff)
downloadgo-753ad5e1d59db9073abba07627723fa3267a52fd.tar.gz
go-753ad5e1d59db9073abba07627723fa3267a52fd.zip
spec: document that trailing comma is valid after index in index expressions
At parse time we don't know if a[i] is an index expression or a type (or function) instantiation. Because instantiations accept a list of type arguments, and argument lists permit a trailing comma, a[i,] is either an instantiation or index expression. Document that a trailing comma is permitted in the syntax for index expressions. For comparison, the same problem arises with conversions which cannot be distinguished from function calls at parse time. The spec also permits a trailing comma for conversions T(x,). The grammar adjustment is the same (see line 5239). Fixes #55007. Change-Id: Ib9101efe52031589eb95a428cc6dff940d939f9e Reviewed-on: https://go-review.googlesource.com/c/go/+/452618 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Robert Griesemer <gri@google.com> Auto-Submit: Robert Griesemer <gri@google.com>
Diffstat (limited to 'doc/go_spec.html')
-rw-r--r--doc/go_spec.html4
1 files changed, 2 insertions, 2 deletions
diff --git a/doc/go_spec.html b/doc/go_spec.html
index 3dcab9c4a6..630012ded8 100644
--- a/doc/go_spec.html
+++ b/doc/go_spec.html
@@ -1,6 +1,6 @@
<!--{
"Title": "The Go Programming Language Specification",
- "Subtitle": "Version of November 10, 2022",
+ "Subtitle": "Version of November 21, 2022",
"Path": "/ref/spec"
}-->
@@ -3305,7 +3305,7 @@ PrimaryExpr =
PrimaryExpr Arguments .
Selector = "." identifier .
-Index = "[" Expression "]" .
+Index = "[" Expression [ "," ] "]" .
Slice = "[" [ Expression ] ":" [ Expression ] "]" |
"[" [ Expression ] ":" Expression ":" Expression "]" .
TypeAssertion = "." "(" Type ")" .