From 705534bd309c8db6b2f616ee29b83dc5483ed4df Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=A9my=20Oudompheng?= Date: Sat, 22 Sep 2012 05:54:05 +1000 Subject: [PATCH] [release-branch.go1] cmd/gc: avoid an internal error on invalid type switch. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit ««« backport 254232c99b3e 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 »»» --- src/cmd/gc/swt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/gc/swt.c b/src/cmd/gc/swt.c index f1a95587fd..4079b67da2 100644 --- a/src/cmd/gc/swt.c +++ b/src/cmd/gc/swt.c @@ -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", -- 2.50.0