From: Russ Cox Date: Tue, 15 May 2012 16:51:58 +0000 (-0400) Subject: cmd/gc: make append(nil, x) error more precise X-Git-Tag: go1.1rc2~3204 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=fcc1f2ac557602f4097e498fa4dd879fb5a680a5;p=gostls13.git 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 --- diff --git a/src/cmd/gc/typecheck.c b/src/cmd/gc/typecheck.c index e98d538572..02d6cc4777 100644 --- a/src/cmd/gc/typecheck.c +++ b/src/cmd/gc/typecheck.c @@ -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; }