summaryrefslogtreecommitdiff
path: root/parse/type.c
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2016-06-21 22:33:00 -0700
committerOri Bernstein <ori@eigenstate.org>2016-06-21 22:33:00 -0700
commitf4c04dca98997d3161158b0f3aa755e53cc07c81 (patch)
tree3f2317b00ec16ceb14eae38ec54d1ef979570d82 /parse/type.c
parentd3ab6d19ae584c5b10d8d7391811f3f26880aa50 (diff)
downloadmc-f4c04dca98997d3161158b0f3aa755e53cc07c81.tar.gz
Don't accidentally duck type unions.
std.option is not the same as any union with `Some x; `None.
Diffstat (limited to 'parse/type.c')
-rw-r--r--parse/type.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/parse/type.c b/parse/type.c
index df123d1..7b1adc5 100644
--- a/parse/type.c
+++ b/parse/type.c
@@ -486,21 +486,30 @@ static int fmtstruct(char *buf, size_t len, Bitset *visited, Type *t)
static int fmtunion(char *buf, size_t len, Bitset *visited, Type *t)
{
- size_t i;
- char *end, *p;
- char *name;
char subbuf[512];
+ char *name, *ns, *sep;
+ char *end, *p;
+ size_t i;
+ Node *n;
p = buf;
end = p + len;
p += bprintf(p, end - p, "union\n");
for (i = 0; i < t->nmemb; i++) {
- name = namestr(t->udecls[i]->name);
+ n = t->udecls[i]->name;
+ if (n->name.ns) {
+ sep = ".";
+ ns = n->name.ns;
+ } else {
+ sep = "";
+ ns = "";
+ }
+ name = n->name.name;
if (t->udecls[i]->etype) {
tybfmt(subbuf, sizeof subbuf, visited, t->udecls[i]->etype);
- p += bprintf(p, end - p, "\t`%s %s\n", name, subbuf);
+ p += bprintf(p, end - p, "\t`%s%s%s %s\n", ns, sep, name, subbuf);
} else {
- p += bprintf(p, end - p, "\t`%s\n", name);
+ p += bprintf(p, end - p, "\t`%s%s%s\n", ns, sep, name);
}
}
p += bprintf(p, end - p, ";;");