Commit 7cf48254 authored by Luuk van Dijk's avatar Luuk van Dijk

gc: small fixes to fmt.c

don't crash when printing error messages about symbols in a garbled state.
render OCOMPLIT in export mode.

R=rsc
CC=golang-dev
https://golang.org/cl/5466045
parent e1b1a5fe
......@@ -511,7 +511,8 @@ symfmt(Fmt *fp, Sym *s)
return fmtprint(fp, "%s.%s", s->pkg->name, s->name); // dcommontype, typehash
return fmtprint(fp, "%s.%s", s->pkg->prefix, s->name); // (methodsym), typesym, weaksym
case FExp:
return fmtprint(fp, "@\"%Z\".%s", s->pkg->path, s->name);
if(s->pkg != builtinpkg)
return fmtprint(fp, "@\"%Z\".%s", s->pkg->path, s->name);
}
}
......@@ -1073,7 +1074,9 @@ exprfmt(Fmt *f, Node *n, int prec)
return fmtprint(f, "%T", n->type);
case OTARRAY:
return fmtprint(f, "[]%N", n->left);
if(n->left)
return fmtprint(f, "[]%N", n->left);
return fmtprint(f, "[]%N", n->right); // happens before typecheck
case OTPAREN:
return fmtprint(f, "(%N)", n->left);
......@@ -1109,7 +1112,9 @@ exprfmt(Fmt *f, Node *n, int prec)
return fmtprint(f, "%T { %H }", n->type, n->nbody);
case OCOMPLIT:
return fmtstrcpy(f, "composite literal");
if(fmtmode == FErr)
return fmtstrcpy(f, "composite literal");
return fmtprint(f, "%N{ %,H }", n->right, n->list);
case OPTRLIT:
return fmtprint(f, "&%N", n->left);
......@@ -1401,7 +1406,7 @@ Sconv(Fmt *fp)
if(s == S)
return fmtstrcpy(fp, "<S>");
if(s->name[0] == '_' && s->name[1] == '\0')
if(s->name && s->name[0] == '_' && s->name[1] == '\0')
return fmtstrcpy(fp, "_");
sf = fp->flags;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment