]> Cypherpunks repositories - gostls13.git/commitdiff
gc: const nil bug
authorRuss Cox <rsc@golang.org>
Sat, 11 Sep 2010 19:47:56 +0000 (15:47 -0400)
committerRuss Cox <rsc@golang.org>
Sat, 11 Sep 2010 19:47:56 +0000 (15:47 -0400)
Fixes #1073.

R=ken2
CC=golang-dev
https://golang.org/cl/2169043

src/cmd/gc/walk.c
test/const1.go

index e51b750b6c2e2ce78fa55aaeac495c2e80e45f2e..fc8f19ec132cdb8ed416ef98f9c3f729a1c608a6 100644 (file)
@@ -261,6 +261,10 @@ walkdef(Node *n)
                        yyerror("const initializer must be constant");
                        goto ret;
                }
+               if(isconst(e, CTNIL)) {
+                       yyerror("const initializer cannot be nil");
+                       goto ret;
+               }
                t = n->type;
                if(t != T) {
                        convlit(&e, t);
index 427d61e59c3b748a868cae67322348e3f7e8d9f5..cf07055cfa307d673db7fe46d524b512b480be61 100644 (file)
@@ -77,3 +77,5 @@ func main() {
        f(String)       // ERROR "convert|wrong type|cannot|incompatible"
        f(Bool) // ERROR "convert|wrong type|cannot|incompatible"
 }
+
+const ptr = nil  // ERROR "const.*nil"