Commit 9fdd0435 authored by Russ Cox's avatar Russ Cox

[release-branch.go1] cmd/gc: make append(nil, x) error more precise

««« backport 4732bf6f874f
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

»»»
parent fd2dfebd
...@@ -1140,6 +1140,10 @@ reswitch: ...@@ -1140,6 +1140,10 @@ reswitch:
goto error; goto error;
n->type = t; n->type = t;
if(!isslice(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); yyerror("first argument to append must be slice; have %lT", t);
goto error; goto error;
} }
......
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