1
0
mirror of https://github.com/golang/go synced 2024-09-24 05:10:13 -06:00

new, stricter interface rule:

in x.(T) x cannot be a nil (uninitialized) interface variable.

remove TODO per discussion.

DELTA=3  (1 added, 1 deleted, 1 changed)
OCL=29123
CL=29134
This commit is contained in:
Russ Cox 2009-05-20 18:16:04 -07:00
parent 787dd4d3f3
commit b89a54e5c6

View File

@ -2210,7 +2210,8 @@ x.(T)
</pre>
<p>
asserts that the value stored in <code>x</code> is of type <code>T</code>.
asserts that <code>x</code> is not the zero interface value
and that the value stored in <code>x</code> is of type <code>T</code>.
The notation <code>x.(T)</code> is called a <i>type assertion</i>.
The type of <code>x</code> must be an interface type.
</p>
@ -2220,7 +2221,6 @@ that the dynamic type of <code>x</code> is identical to the type <code>T</code>
(§Type identity and compatibility).
If <code>T</code> is an interface type, <code>x.(T)</code> asserts that the dynamic type
of <code>T</code> implements the interface <code>T</code> (§Interface types).
<font color=red>TODO: gri wants an error if x is already of type T.</font>
</p>
<p>
If the type assertion holds, the value of the expression is the value