From 3c495839fe6e711b9161f8efc2d1bd474bf60916 Mon Sep 17 00:00:00 2001
From: Robert Griesemer
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,] …
-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.