File tree Expand file tree Collapse file tree 1 file changed +36
-1
lines changed Expand file tree Collapse file tree 1 file changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -984,7 +984,42 @@ var f1 func(_ x(T))
984984var f2 func ((x (T)))
985985```
986986
987- ### Embedding a parameterized interface type
987+ ### Embedding a parameterized type in a struct
988+
989+ There is a parsing ambiguity when embedding a parameterized type
990+ in a struct type.
991+
992+ ``` Go
993+ type S1 (type T ) struct {
994+ f T
995+ }
996+
997+ type S2 struct {
998+ S1 (int )
999+ }
1000+ ```
1001+
1002+ In this example we don't know whether struct ` S2 ` has a single
1003+ field named ` S1 ` of type ` (int) ` , or whether we
1004+ are trying to embed the instantiated type ` S1(int) ` into ` S2 ` .
1005+
1006+ For backward compatibility, we treat this as the former case: ` S2 ` has
1007+ a field named ` S1 ` .
1008+
1009+ In order to embed an instantiated type in a struct, we could require that
1010+ extra parentheses be used.
1011+
1012+ ``` Go
1013+ type S2 struct {
1014+ (S1 (int ))
1015+ }
1016+ ```
1017+
1018+ This is currently not supported by the language, so this would suggest
1019+ generally extending the language to permit types embedded in structs to
1020+ be parenthesized.
1021+
1022+ ### Embedding a parameterized interface type in an interface
9881023
9891024There is a parsing ambiguity when embedding a parameterized interface
9901025type in another interface type.
You can’t perform that action at this time.
0 commit comments