]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/gc: make append(nil, x) error more precise
authorRuss Cox <rsc@golang.org>
Tue, 15 May 2012 16:51:58 +0000 (12:51 -0400)
committerRuss Cox <rsc@golang.org>
Tue, 15 May 2012 16:51:58 +0000 (12:51 -0400)
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

index e98d538572484608879db7a2db03896cf806fc52..02d6cc477726bae95afe90ad8236cdf5e7007ba5 100644 (file)
@@ -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;
                }