diff options
author | Robert Griesemer <gri@golang.org> | 2021-12-10 15:35:46 -0800 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2021-12-13 18:41:35 +0000 |
commit | 083ef5462494e81ee23316245c5d65085a3f62d9 (patch) | |
tree | 066b1b70238d6580d86b8107c17680ca61b9232e /doc | |
parent | acc65b47e12e2ba061b8ab4f86b183d039072776 (diff) | |
download | go-git-083ef5462494e81ee23316245c5d65085a3f62d9.tar.gz |
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 <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'doc')
-rw-r--r-- | doc/go_spec.html | 10 |
1 files changed, 6 insertions, 4 deletions
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 @@ <!--{ "Title": "The Go Programming Language Specification - Go 1.18 Draft (incomplete)", - "Subtitle": "Version of Nov 29, 2021", + "Subtitle": "Version of Dec 13, 2021", "Path": "/ref/spec" }--> @@ -4782,14 +4782,16 @@ in any of these cases: </li> <li> ignoring struct tags (see below), - <code>x</code>'s type and <code>T</code> have <a href="#Type_identity">identical</a> - <a href="#Types">underlying types</a>. + <code>x</code>'s type and <code>T</code> are not + <a href="#Type_parameters">type parameters</a> but have + <a href="#Type_identity">identical</a> <a href="#Types">underlying types</a>. </li> <li> ignoring struct tags (see below), <code>x</code>'s type and <code>T</code> are pointer types that are not <a href="#Types">named types</a>, - and their pointer base types have identical underlying types. + and their pointer base types are not type parameters but + have identical underlying types. </li> <li> <code>x</code>'s type and <code>T</code> are both integer or floating |