Commit 3b576a77 authored by Robert Griesemer's avatar Robert Griesemer

fix for incorrect type switch clause:

- nil is not a keyword
- type -> Type

R=rsc
DELTA=10  (4 added, 0 deleted, 6 changed)
OCL=30433
CL=30435
parent 410ba586
...@@ -7,6 +7,7 @@ Open issues: ...@@ -7,6 +7,7 @@ Open issues:
- declaration "type T S" strips methods of S. why/why not? - declaration "type T S" strips methods of S. why/why not?
- no mechanism to declare a local type name: type T P.T - no mechanism to declare a local type name: type T P.T
Todo's: Todo's:
[ ] document illegality of package-external tuple assignments to structs [ ] document illegality of package-external tuple assignments to structs
w/ private fields: P.T(1, 2) illegal since same as P.T(a: 1, b: 2) for w/ private fields: P.T(1, 2) illegal since same as P.T(a: 1, b: 2) for
...@@ -447,7 +448,7 @@ because the size of the pointer itself is always known. ...@@ -447,7 +448,7 @@ because the size of the pointer itself is always known.
interface fit in here.) interface fit in here.)
</p> </p>
<p> <p>
A type may have a method set associated with it A type may have a <i>method set</i> associated with it
(§Interface types, §Method declarations). (§Interface types, §Method declarations).
The method set of an interface type (§Interface types) is its interface. The method set of an interface type (§Interface types) is its interface.
The method set of any other named type <code>T</code> The method set of any other named type <code>T</code>
...@@ -1341,7 +1342,7 @@ If an identifier satisfies these two conditions: ...@@ -1341,7 +1342,7 @@ If an identifier satisfies these two conditions:
declared at the top level; declared at the top level;
</ol> </ol>
<p> <p>
it will be exported automatically. it will be exported.
</p> </p>
<h3>Const declarations</h3> <h3>Const declarations</h3>
...@@ -3303,10 +3304,13 @@ in the type assertion. ...@@ -3303,10 +3304,13 @@ in the type assertion.
TypeSwitchStmt = "switch" [ [ SimpleStmt ] ";" ] TypeSwitchGuard "{" { TypeCaseClause } "}" . TypeSwitchStmt = "switch" [ [ SimpleStmt ] ";" ] TypeSwitchGuard "{" { TypeCaseClause } "}" .
TypeSwitchGuard = identifier ":=" Expression "." "(" "type" ")" . TypeSwitchGuard = identifier ":=" Expression "." "(" "type" ")" .
TypeCaseClause = TypeSwitchCase ":" [ StatementList ] . TypeCaseClause = TypeSwitchCase ":" [ StatementList ] .
TypeSwitchCase = "case" ( type | "nil" ) | "default" . TypeSwitchCase = "case" Type | "default" .
</pre> </pre>
<p> <p>
As a special case, the type in the type switch case may be an
identifier denoting the predeclared constant <code>nil</code>
(§Predeclared identifiers).
If the interface value equals <code>nil</code>, If the interface value equals <code>nil</code>,
only an explict <code>nil</code> case or "default" only an explict <code>nil</code> case or "default"
case will execute. case will execute.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment