]> Cypherpunks repositories - gostls13.git/commitdiff
spec: add missing optional type arguments after TypeName in syntax
authorRobert Griesemer <gri@golang.org>
Mon, 13 Jun 2022 17:18:38 +0000 (10:18 -0700)
committerRobert Griesemer <gri@golang.org>
Mon, 13 Jun 2022 19:06:49 +0000 (19:06 +0000)
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>
doc/go_spec.html

index 37580a83b7e2e10ec9bdca7c1e303a83675fd4fa..170c359c87bce621b62e539778e27347c27e3641 100644 (file)
@@ -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"
 }-->
 
@@ -1025,7 +1025,7 @@ be <a href="#Uniqueness_of_identifiers">unique</a>.
 <pre class="ebnf">
 StructType    = "struct" "{" { FieldDecl ";" } "}" .
 FieldDecl     = (IdentifierList Type | EmbeddedField) [ Tag ] .
-EmbeddedField = [ "*" ] TypeName .
+EmbeddedField = [ "*" ] TypeName [ TypeArgs ] .
 Tag           = string_lit .
 </pre>
 
@@ -3029,7 +3029,7 @@ Each element may optionally be preceded by a corresponding key.
 <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 .