]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/gc: avoid crash in %N print
authorRuss Cox <rsc@golang.org>
Sun, 7 Oct 2012 19:35:01 +0000 (15:35 -0400)
committerRuss Cox <rsc@golang.org>
Sun, 7 Oct 2012 19:35:01 +0000 (15:35 -0400)
R=ken2
CC=golang-dev
https://golang.org/cl/6609052

src/cmd/gc/fmt.c

index 5a1f6793013f63c2714d7a1587731f71a942e158..61709c2862992e926ad21029a2d17e5adbae85f7 100644 (file)
@@ -1086,9 +1086,9 @@ exprfmt(Fmt *f, Node *n, int prec)
        case OLITERAL:  // this is a bit of a mess
                if(fmtmode == FErr && n->sym != S)
                        return fmtprint(f, "%S", n->sym);
-               if(n->val.ctype == CTNIL)
+               if(n->val.ctype == CTNIL && n->orig != N)
                        n = n->orig; // if this node was a nil decorated with at type, print the original naked nil
-               if(n->type != types[n->type->etype] && n->type != idealbool && n->type != idealstring) {
+               if(n->type != T && n->type != types[n->type->etype] && n->type != idealbool && n->type != idealstring) {
                        // Need parens when type begins with what might
                        // be misinterpreted as a unary operator: * or <-.
                        if(isptr[n->type->etype] || (n->type->etype == TCHAN && n->type->chan == Crecv))