mirror of
https://github.com/golang/go
synced 2024-11-23 01:30:02 -07:00
spec: add missing optional type arguments after TypeName in syntax
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>
This commit is contained in:
parent
2c52465cb3
commit
4703546a29
@ -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 .
|
||||
|
Loading…
Reference in New Issue
Block a user