]> Cypherpunks repositories - gostls13.git/commitdiff
fix bug involving typed nil constants:
authorRuss Cox <rsc@golang.org>
Tue, 7 Jul 2009 04:37:29 +0000 (21:37 -0700)
committerRuss Cox <rsc@golang.org>
Tue, 7 Jul 2009 04:37:29 +0000 (21:37 -0700)
interface = (*int)(nil) is not the same as
interface = nil.

package main
func main() {
var x interface{} = (*int)(nil);
println(x.(*int));
}

R=ken
OCL=31232
CL=31232

src/cmd/gc/const.c

index 5ce4ebee7404b4d057c70bf5ea3796324a891876..d45e6136a1920903ff586ab856eb39312713e050 100644 (file)
@@ -94,7 +94,7 @@ convlit1(Node *n, Type *t, int explicit)
                goto bad;
 
        if(et == TINTER) {
-               if(ct == CTNIL) {
+               if(ct == CTNIL && n->type == types[TNIL]) {
                        n->type = t;
                        return;
                }