]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/gc: print expression in 'duplicate case in switch' error
authorRuss Cox <rsc@golang.org>
Fri, 20 Sep 2013 19:15:43 +0000 (15:15 -0400)
committerRuss Cox <rsc@golang.org>
Fri, 20 Sep 2013 19:15:43 +0000 (15:15 -0400)
The line number alone does not help when the line is
case '~', '*', '(', ')', '[', ']', '{', '}', '?', ':', ';', ',', '*', '%', '^', '!', '=', '<', '>', '+', '-', '&', '|':

R=ken2
CC=golang-dev
https://golang.org/cl/13431046

src/cmd/gc/swt.c

index ced07790ac40ed0eed58631ba74569c9dfcb0db0..d6aa021a9ca5743600193049069f6be931e2f23b 100644 (file)
@@ -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;
        }