Skip to content

Commit

Permalink
spec: add missing optional type arguments after TypeName in syntax
Browse files Browse the repository at this point in the history
Types may be generic, so each occurrence of a TypeName may be
followed by optional type arguments. Add the missing syntactic
(EBNF) factor.

The syntax of type names followed by type arguments matches the
syntax of operand names followed by type arguments (operands may
also be types, or generic functions, among other things). This
opens the door to factoring out this shared syntax, but it will
also require some adjustments to prose to make it work well.
Leaving for another change.

Fixes #53240.

Change-Id: I15212225c28b27f7621e3ca80dfbd131f6b7eada
Reviewed-on: https://go-review.googlesource.com/c/go/+/411918
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
  • Loading branch information
griesemer committed Jun 13, 2022
1 parent 2c52465 commit 4703546
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions doc/go_spec.html
@@ -1,6 +1,6 @@
<!--{
"Title": "The Go Programming Language Specification",
"Subtitle": "Version of May 12, 2022",
"Subtitle": "Version of June 13, 2022",
"Path": "/ref/spec"
}-->

Expand Down Expand Up @@ -1025,7 +1025,7 @@ <h3 id="Struct_types">Struct types</h3>
<pre class="ebnf">
StructType = "struct" "{" { FieldDecl ";" } "}" .
FieldDecl = (IdentifierList Type | EmbeddedField) [ Tag ] .
EmbeddedField = [ "*" ] TypeName .
EmbeddedField = [ "*" ] TypeName [ TypeArgs ] .
Tag = string_lit .
</pre>

Expand Down Expand Up @@ -3029,7 +3029,7 @@ <h3 id="Composite_literals">Composite literals</h3>
<pre class="ebnf">
CompositeLit = LiteralType LiteralValue .
LiteralType = StructType | ArrayType | "[" "..." "]" ElementType |
SliceType | MapType | TypeName .
SliceType | MapType | TypeName [ TypeArgs ] .
LiteralValue = "{" [ ElementList [ "," ] ] "}" .
ElementList = KeyedElement { "," KeyedElement } .
KeyedElement = [ Key ":" ] Element .
Expand Down

0 comments on commit 4703546

Please sign in to comment.