cmd/gc: make append(nil, x) error more precise

Before:
./x.go:6: first argument to append must be slice; have nil

After:
./x.go:6: first argument to append must be typed slice; have untyped nil

Fixes #3616.

R=ken2
CC=golang-dev
https://golang.org/cl/6209067
This commit is contained in:
Russ Cox 2012-05-15 12:51:58 -04:00
parent 4a5a5b20a5
commit fcc1f2ac55
1 changed files with 4 additions and 0 deletions

View File

@ -1140,6 +1140,10 @@ reswitch:
goto error;
n->type = t;
if(!isslice(t)) {
if(isconst(args->n, CTNIL)) {
yyerror("first argument to append must be typed slice; have untyped nil", t);
goto error;
}
yyerror("first argument to append must be slice; have %lT", t);
goto error;
}