]> Cypherpunks repositories - gostls13.git/commitdiff
compiler falut for forgetting
authorKen Thompson <ken@golang.org>
Fri, 3 Apr 2009 01:06:43 +0000 (18:06 -0700)
committerKen Thompson <ken@golang.org>
Fri, 3 Apr 2009 01:06:43 +0000 (18:06 -0700)
the assignment on a type switch

R=r
OCL=27048
CL=27048

src/cmd/gc/swt.c

index 70d1a9e4777853b126be05ebd8211131e30c8e83..263496701f0210544791426e70729508d411b4ff 100644 (file)
@@ -763,6 +763,13 @@ typeswitch(Node *sw)
        Case *c, *c0, *c1;
        int ncase;
 
+       if(sw->ntest == nil)
+               return;
+       if(sw->ntest->right == nil) {
+               setlineno(sw);
+               yyerror("type switch must have an assignment");
+               return;
+       }
        walktype(sw->ntest->right, Erv);
        if(!istype(sw->ntest->right->type, TINTER)) {
                yyerror("type switch must be on an interface");