From 083ef5462494e81ee23316245c5d65085a3f62d9 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Fri, 10 Dec 2021 15:35:46 -0800 Subject: [PATCH] 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 --- doc/go_spec.html | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/doc/go_spec.html b/doc/go_spec.html index 2832b0739db15..cb57aa301cbf4 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -1,6 +1,6 @@ @@ -4782,14 +4782,16 @@

Conversions

  • 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