From fcc1f2ac557602f4097e498fa4dd879fb5a680a5 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 15 May 2012 12:51:58 -0400 Subject: [PATCH] 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; } -- 2.48.1