Skip to content

Commit

Permalink
[release-branch.go1] cmd/gc: make append(nil, x) error more precise
Browse files Browse the repository at this point in the history
««« 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

»»»
  • Loading branch information
rsc committed Jun 13, 2012
1 parent fd2dfeb commit 9fdd043
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/cmd/gc/typecheck.c
Original file line number Diff line number Diff line change
Expand Up @@ -1140,6 +1140,10 @@ typecheck1(Node **np, int top)
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;
}
Expand Down

0 comments on commit 9fdd043

Please sign in to comment.