From: Russ Cox Date: Fri, 20 Sep 2013 19:15:43 +0000 (-0400) Subject: cmd/gc: print expression in 'duplicate case in switch' error X-Git-Tag: go1.2rc2~157 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=36f84809656d92ebe9a7c43e7395239903fcde1a;p=gostls13.git cmd/gc: print expression in 'duplicate case in switch' error The line number alone does not help when the line is case '~', '*', '(', ')', '[', ']', '{', '}', '?', ':', ';', ',', '*', '%', '^', '!', '=', '<', '>', '+', '-', '&', '|': R=ken2 CC=golang-dev https://golang.org/cl/13431046 --- diff --git a/src/cmd/gc/swt.c b/src/cmd/gc/swt.c index ced07790ac..d6aa021a9c 100644 --- a/src/cmd/gc/swt.c +++ b/src/cmd/gc/swt.c @@ -415,7 +415,7 @@ mkcaselist(Node *sw, int arg) break; if(!eqtype(c1->node->left->type, c2->node->left->type)) continue; - yyerrorl(c2->node->lineno, "duplicate case in switch\n\tprevious case at %L", c1->node->lineno); + yyerrorl(c2->node->lineno, "duplicate case %T in type switch\n\tprevious case at %L", c2->node->left->type, c1->node->lineno); } } break; @@ -427,7 +427,7 @@ mkcaselist(Node *sw, int arg) if(exprcmp(c1, c1->link) != 0) continue; setlineno(c1->link->node); - yyerror("duplicate case in switch\n\tprevious case at %L", c1->node->lineno); + yyerror("duplicate case %N in switch\n\tprevious case at %L", c1->node->left, c1->node->lineno); } break; }