1
0
mirror of https://github.com/golang/go synced 2024-11-20 09:04:44 -07:00

cmd/gc: avoid an internal error on invalid type switch.

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
This commit is contained in:
Rémy Oudompheng 2012-07-12 23:31:36 +02:00
parent bd0bb2bc39
commit 1ca7bc268b

View 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",