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,6 +511,7 @@ symfmt(Fmt *fp, Sym *s) ...@@ -511,6 +511,7 @@ symfmt(Fmt *fp, Sym *s)
return fmtprint(fp, "%s.%s", s->pkg->name, s->name); // dcommontype, typehash 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 return fmtprint(fp, "%s.%s", s->pkg->prefix, s->name); // (methodsym), typesym, weaksym
case FExp: case FExp:
if(s->pkg != builtinpkg)
return fmtprint(fp, "@\"%Z\".%s", s->pkg->path, s->name); return fmtprint(fp, "@\"%Z\".%s", s->pkg->path, s->name);
} }
} }
...@@ -1073,7 +1074,9 @@ exprfmt(Fmt *f, Node *n, int prec) ...@@ -1073,7 +1074,9 @@ exprfmt(Fmt *f, Node *n, int prec)
return fmtprint(f, "%T", n->type); return fmtprint(f, "%T", n->type);
case OTARRAY: case OTARRAY:
if(n->left)
return fmtprint(f, "[]%N", n->left); return fmtprint(f, "[]%N", n->left);
return fmtprint(f, "[]%N", n->right); // happens before typecheck
case OTPAREN: case OTPAREN:
return fmtprint(f, "(%N)", n->left); return fmtprint(f, "(%N)", n->left);
...@@ -1109,7 +1112,9 @@ exprfmt(Fmt *f, Node *n, int prec) ...@@ -1109,7 +1112,9 @@ exprfmt(Fmt *f, Node *n, int prec)
return fmtprint(f, "%T { %H }", n->type, n->nbody); return fmtprint(f, "%T { %H }", n->type, n->nbody);
case OCOMPLIT: case OCOMPLIT:
if(fmtmode == FErr)
return fmtstrcpy(f, "composite literal"); return fmtstrcpy(f, "composite literal");
return fmtprint(f, "%N{ %,H }", n->right, n->list);
case OPTRLIT: case OPTRLIT:
return fmtprint(f, "&%N", n->left); return fmtprint(f, "&%N", n->left);
...@@ -1401,7 +1406,7 @@ Sconv(Fmt *fp) ...@@ -1401,7 +1406,7 @@ Sconv(Fmt *fp)
if(s == S) if(s == S)
return fmtstrcpy(fp, "<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, "_"); return fmtstrcpy(fp, "_");
sf = fp->flags; 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