From: Robert Griesemer Date: Fri, 10 Dec 2021 23:35:46 +0000 (-0800) Subject: spec: fix conversion rules (match implementation) X-Git-Tag: go1.18beta1~12 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=083ef5462494e81ee23316245c5d65085a3f62d9;p=gostls13.git spec: fix conversion rules (match implementation) As written, the conversion P(x), where P and the type of x are type parameters with identical underlying types (i.e., identical constraints), is valid. However, unless the type of x and P are identical (which is covered with the assignability rule), such a conversion is not valid in general (consider the case where both type parameters are different type parameters with constraint "any"). This change adjusts the rules to prohibit type parameters in this case. The same reasoning applies and the analogue change is made for pointer types. The type checker already implements these updated rules. Change-Id: Id90187900cb2820f6a0a0cf582cf26cdf8addbce Reviewed-on: https://go-review.googlesource.com/c/go/+/371074 Trust: Robert Griesemer Reviewed-by: Ian Lance Taylor --- diff --git a/doc/go_spec.html b/doc/go_spec.html index 2832b0739d..cb57aa301c 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -1,6 +1,6 @@ @@ -4782,14 +4782,16 @@ in any of these cases:
  • ignoring struct tags (see below), - x's type and T have identical - underlying types. + x's type and T are not + type parameters but have + identical underlying types.
  • ignoring struct tags (see below), x's type and T are pointer types that are not named types, - and their pointer base types have identical underlying types. + and their pointer base types are not type parameters but + have identical underlying types.
  • x's type and T are both integer or floating