]> Cypherpunks repositories - gostls13.git/commitdiff
gc: avoid saying same error 3 times
authorRuss Cox <rsc@golang.org>
Sat, 2 Apr 2011 00:52:38 +0000 (20:52 -0400)
committerRuss Cox <rsc@golang.org>
Sat, 2 Apr 2011 00:52:38 +0000 (20:52 -0400)
R=ken2
CC=golang-dev
https://golang.org/cl/4316051

src/cmd/gc/const.c
src/cmd/gc/subr.c
test/ddd1.go

index 0cc26fc3b51d5dc019fe4003b138a0f1aef987c0..a36ec68c0aa27e9cb0a1172815339e7a0c3c9ea6 100644 (file)
@@ -136,7 +136,6 @@ convlit1(Node **np, Type *t, int explicit)
        case CTNIL:
                switch(et) {
                default:
-                       yyerror("cannot use nil as %T", t);
                        n->type = T;
                        goto bad;
 
index 26b9a40a290a0860fc1a0c81a098a29b6457c056..b4c58d10d72434653d797c8665febd6217df0d45 100644 (file)
@@ -2053,13 +2053,16 @@ Node*
 assignconv(Node *n, Type *t, char *context)
 {
        int op;
-       Node *r;
+       Node *r, *old;
        char *why;
        
        if(n == N || n->type == T)
                return n;
 
+       old = n;
+       old->diag++;  // silence errors about n; we'll issue one below
        defaultlit(&n, t);
+       old->diag--;
        if(t->etype == TBLANK)
                return n;
 
index ff6342843a96ce785bb11f89b53452e4a5d3ea12..a0bc73814fd551e256aff9ccb4774607ed76f0e3 100644 (file)
@@ -15,7 +15,7 @@ var (
        _ = sum()
        _ = sum(1.0, 2.0)
        _ = sum(1.5)      // ERROR "integer"
-       _ = sum("hello")  // ERROR "convert|incompatible"
+       _ = sum("hello")  // ERROR "string.*as type int|incompatible"
        _ = sum([]int{1}) // ERROR "slice literal.*as type int|incompatible"
 )