From 54191126e49bb6504012fc8aacdadf273683750a Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sun, 7 Oct 2012 15:35:01 -0400 Subject: [PATCH] cmd/gc: avoid crash in %N print R=ken2 CC=golang-dev https://golang.org/cl/6609052 --- src/cmd/gc/fmt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cmd/gc/fmt.c b/src/cmd/gc/fmt.c index 5a1f679301..61709c2862 100644 --- a/src/cmd/gc/fmt.c +++ b/src/cmd/gc/fmt.c @@ -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)) -- 2.48.1