]> Cypherpunks repositories - gostls13.git/commitdiff
error message fixes
authorRuss Cox <rsc@golang.org>
Wed, 9 Sep 2009 08:21:20 +0000 (01:21 -0700)
committerRuss Cox <rsc@golang.org>
Wed, 9 Sep 2009 08:21:20 +0000 (01:21 -0700)
x == nil
x.go:5: cannot use nil as bool

c := x.(type);
x.go:88: use of .(type) outside type switch

R=ken
OCL=34476
CL=34476

src/cmd/gc/const.c
src/cmd/gc/typecheck.c

index 16daab043e677d10b3d32b8b20c36708e75a697a..db28b3c9d4ee70caf8961e55ecbd39adcf00b00f 100644 (file)
@@ -132,6 +132,8 @@ convlit1(Node **np, Type *t, int explicit)
        case CTNIL:
                switch(et) {
                default:
+                       yyerror("cannot use nil as %T", t);
+                       n->type = T;
                        goto bad;
 
                case TSTRING:
index 7665cbf3c494a890441ea05a30b01fe41672b7ce..d364e5fcc6fe15366c2d2f13db4470d3db4dcd02 100644 (file)
@@ -307,6 +307,8 @@ reswitch:
                defaultlit2(&l, &r, 0);
                n->left = l;
                n->right = r;
+               if(l->type == T || r->type == T)
+                       goto error;
                t = l->type;
                if(t->etype == TIDEAL)
                        t = r->type;
@@ -960,9 +962,8 @@ reswitch:
                goto ret;
 
        case OTYPESW:
-               ok |= Etop;
-               typecheck(&n->right, Erv);
-               goto ret;
+               yyerror("use of .(type) outside type switch");
+               goto error;
 
        case OXCASE:
                ok |= Etop;