Commit 83bdb805 authored by Russ Cox's avatar Russ Cox

error message fixes

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
parent e780fa86
...@@ -132,6 +132,8 @@ convlit1(Node **np, Type *t, int explicit) ...@@ -132,6 +132,8 @@ convlit1(Node **np, Type *t, int explicit)
case CTNIL: case CTNIL:
switch(et) { switch(et) {
default: default:
yyerror("cannot use nil as %T", t);
n->type = T;
goto bad; goto bad;
case TSTRING: case TSTRING:
......
...@@ -307,6 +307,8 @@ reswitch: ...@@ -307,6 +307,8 @@ reswitch:
defaultlit2(&l, &r, 0); defaultlit2(&l, &r, 0);
n->left = l; n->left = l;
n->right = r; n->right = r;
if(l->type == T || r->type == T)
goto error;
t = l->type; t = l->type;
if(t->etype == TIDEAL) if(t->etype == TIDEAL)
t = r->type; t = r->type;
...@@ -960,9 +962,8 @@ reswitch: ...@@ -960,9 +962,8 @@ reswitch:
goto ret; goto ret;
case OTYPESW: case OTYPESW:
ok |= Etop; yyerror("use of .(type) outside type switch");
typecheck(&n->right, Erv); goto error;
goto ret;
case OXCASE: case OXCASE:
ok |= Etop; ok |= Etop;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment