]> Cypherpunks repositories - gostls13.git/commitdiff
spec: clarify type term restriction for type parameters
authorRobert Griesemer <gri@golang.org>
Wed, 30 Mar 2022 21:13:39 +0000 (14:13 -0700)
committerRobert Griesemer <gri@golang.org>
Thu, 31 Mar 2022 01:01:43 +0000 (01:01 +0000)
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 <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

doc/go_spec.html

index ad12fcfaa99992644d418a969c5562b6e9047a6e..2255b6f8e2464d291d4ecda9da97b3486117db84 100644 (file)
@@ -1,6 +1,6 @@
 <!--{
        "Title": "The Go Programming Language Specification",
-       "Subtitle": "Version of March 10, 2022",
+       "Subtitle": "Version of March 30, 2022",
        "Path": "/ref/spec"
 }-->
 
@@ -1454,7 +1454,8 @@ type Float interface {
 </pre>
 
 <p>
-In a union, a term cannot be a <a href="#Type_parameter_declarations">type parameter</a>, and the type sets of all
+The type <code>T</code> in a term of the form <code>T</code> or <code>~T</code> cannot
+be a <a href="#Type_parameter_declarations">type parameter</a>, 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 <code>P</code>:
 </p>
@@ -1462,7 +1463,7 @@ Given a type parameter <code>P</code>:
 <pre>
 interface {
        P                // illegal: P is a type parameter
-       int |          // 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
 <p>
 For a generic function, type arguments may be provided explicitly, or they
 may be partially or completely <a href="#Type_inference">inferred</a>.
-A generic function that is is <i>not</i> <a href="#Calls">called</a> requires a
+A generic function that is <i>not</i> <a href="#Calls">called</a> 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