From: Robert Griesemer Date: Wed, 30 Mar 2022 21:13:39 +0000 (-0700) Subject: spec: clarify type term restriction for type parameters X-Git-Tag: go1.19beta1~860 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=ea858734be6e711fa2d41fdeb6038ff09e3c7841;p=gostls13.git spec: clarify type term restriction for type parameters Be clear that the type of a term (not the term itself, which may be of the form ~P) cannot be a type parameter. For #50420. Change-Id: I388d57be0618393d7ebe2c74ec04c1ebe3f33f7d Reviewed-on: https://go-review.googlesource.com/c/go/+/396915 Trust: Robert Griesemer Run-TryBot: Robert Griesemer Reviewed-by: Ian Lance Taylor TryBot-Result: Gopher Robot --- diff --git a/doc/go_spec.html b/doc/go_spec.html index ad12fcfaa9..2255b6f8e2 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -1,6 +1,6 @@ @@ -1454,7 +1454,8 @@ type Float interface {

-In a union, a term cannot be a type parameter, and the type sets of all +The type T in a term of the form T or ~T cannot +be a type parameter, and the type sets of all non-interface terms must be pairwise disjoint (the pairwise intersection of the type sets must be empty). Given a type parameter P:

@@ -1462,7 +1463,7 @@ Given a type parameter P:
 interface {
 	P                // illegal: P is a type parameter
-	int | P          // illegal: P is a type parameter
+	int | ~P         // illegal: P is a type parameter
 	~int | MyInt     // illegal: the type sets for ~int and MyInt are not disjoint (~int includes MyInt)
 	float32 | Float  // overlapping type sets but Float is an interface
 }
@@ -4195,7 +4196,7 @@ type parameter list    type arguments    after substitution
 

For a generic function, type arguments may be provided explicitly, or they may be partially or completely inferred. -A generic function that is is not called requires a +A generic function that is not called requires a type argument list for instantiation; if the list is partial, all remaining type arguments must be inferrable. A generic function that is called may provide a (possibly partial) type