Skip to content

Commit

Permalink
error message fixes
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rsc committed Sep 9, 2009
1 parent e780fa8 commit 83bdb80
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/cmd/gc/const.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 4 additions & 3 deletions src/cmd/gc/typecheck.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,8 @@ typecheck(Node **np, int top)
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;
Expand Down Expand Up @@ -960,9 +962,8 @@ typecheck(Node **np, int top)
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;
Expand Down

0 comments on commit 83bdb80

Please sign in to comment.