From: Robert Griesemer Date: Thu, 16 Dec 2021 18:25:07 +0000 (-0800) Subject: spec: describe constraint parsing ambiguity and work-around more precisely X-Git-Tag: go1.18beta2~209 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=3c495839fe6e711b9161f8efc2d1bd474bf60916;p=gostls13.git spec: describe constraint parsing ambiguity and work-around more precisely The new description matches the implementation (CL 370774). Also, in the section on type constraints, use "defines" instead of "determines" because the constraint interface defines the type set which is precisely the set of acceptable type arguments. For #49482. Change-Id: I6f30f49100e8ba8bec0a0f1b450f88cae54312eb Reviewed-on: https://go-review.googlesource.com/c/go/+/372874 Trust: Robert Griesemer Run-TryBot: Robert Griesemer TryBot-Result: Gopher Robot Reviewed-by: Ian Lance Taylor --- diff --git a/doc/go_spec.html b/doc/go_spec.html index ed98f5375f..c0b224f977 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -2604,7 +2604,8 @@ has a corresponding (meta-)type which is called its

A parsing ambiguity arises when the type parameter list for a parameterized type declares a single type parameter with a type constraint of the form *C -or (C): +or (C) where C is not a (possibly parenthesized) +type literal:

@@ -2616,17 +2617,19 @@ type T[P (C)] …
 In these rare cases, the type parameter declaration is indistinguishable from
 the expressions P*C or P(C) and the type declaration
 is parsed as an array type declaration.
-To resolve the ambiguity, embed the constraint in an interface:
+To resolve the ambiguity, embed the constraint in an interface or use a trailing
+comma:
 

 type T[P interface{*C}] …
+type T[P *C,] …
 

Type constraints

-A type constraint is an interface that determines the +A type constraint is an interface that defines the set of permissible type arguments for the respective type parameter and controls the operations supported by values of that type parameter.