From 9fdd043517c7515788b9f59fbd133158997ad6c5 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 13 Jun 2012 16:23:54 -0400 Subject: [PATCH] [release-branch.go1] cmd/gc: make append(nil, x) error more precise MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ««« 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 »»» --- src/cmd/gc/typecheck.c | 4 ++++ 1 file changed, 4 insertions(+) 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; }