]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/gc: avoid an internal error on invalid type switch.
authorRémy Oudompheng <oudomphe@phare.normalesup.org>
Thu, 12 Jul 2012 21:31:36 +0000 (23:31 +0200)
committerRémy Oudompheng <oudomphe@phare.normalesup.org>
Thu, 12 Jul 2012 21:31:36 +0000 (23:31 +0200)
The error was caused by a call to implements() even when
the type switch variable was not an interface.

Fixes #3786.

R=golang-dev, r
CC=golang-dev, remy
https://golang.org/cl/6354102

src/cmd/gc/swt.c

index f1a95587fd679b045978f2d627e6a6d4671bfe72..4079b67da29d101859f801efd5360ce60e22eb4d 100644 (file)
@@ -889,7 +889,7 @@ typecheckswitch(Node *n)
                                                yyerror("%lN is not a type", ll->n);
                                                // reset to original type
                                                ll->n = n->ntest->right;
-                                       } else if(ll->n->type->etype != TINTER && !implements(ll->n->type, t, &missing, &have, &ptr)) {
+                                       } else if(ll->n->type->etype != TINTER && t->etype == TINTER && !implements(ll->n->type, t, &missing, &have, &ptr)) {
                                                if(have && !missing->broke && !have->broke)
                                                        yyerror("impossible type switch case: %lN cannot have dynamic type %T"
                                                                " (wrong type for %S method)\n\thave %S%hT\n\twant %S%hT",