summaryrefslogtreecommitdiff
path: root/parse
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-01-08 12:11:53 -0800
committerOri Bernstein <ori@eigenstate.org>2015-01-08 12:11:53 -0800
commit864a75e776b32d11e890589a0d7e1c0f859c84a7 (patch)
treec4c7ac2abe065acb73ceebf4d9c891defde34d9b /parse
parente2305586e5da4fba9f03ca4a4d2a4ec5a4c830e4 (diff)
downloadmc-864a75e776b32d11e890589a0d7e1c0f859c84a7.tar.gz
Handle errors better.
Diffstat (limited to 'parse')
-rw-r--r--parse/infer.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/parse/infer.c b/parse/infer.c
index 4b534bb..83dcc1e 100644
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -94,9 +94,12 @@ static void ctxstrcall(char *buf, size_t sz, Inferstate *st, Node *n)
static char *nodetystr(Inferstate *st, Node *n, char *s)
{
- if (n->type != Nexpr || !exprtype(n))
+ if (n->type == Nexpr && exprtype(n) != NULL)
+ return tystr(tf(st, exprtype(n)));
+ else if (n->type == Ndecl && decltype(n) != NULL)
+ return tystr(tf(st, decltype(n)));
+ else
return strdup(s);
- return tystr(tf(st, exprtype(n)));
}
/* Tries to give a good string describing the context
@@ -115,7 +118,7 @@ static char *ctxstr(Inferstate *st, Node *n)
break;
case Ndecl:
d = declname(n);
- t = tystr(tf(st, decltype(n)));
+ t = nodetystr(st, n, "unknown");
snprintf(buf, sizeof buf, "%s:%s", d, t);
s = strdup(buf);
free(t);
@@ -144,15 +147,9 @@ static char *ctxstr(Inferstate *st, Node *n)
snprintf(buf, sizeof buf, "<e1:%s> %s <e2:%s>", t1, oppretty[exprop(n)], t2);
break;
case OTpre:
- t1 = tystr(tf(st, exprtype(n)));
- if (!t1)
- t1 = strdup("unknown type");
snprintf(buf, sizeof buf, "%s<e%s>", t1, oppretty[exprop(n)]);
break;
case OTpost:
- t1 = tystr(tf(st, exprtype(n)));
- if (!t1)
- t1 = strdup("unknown type");
snprintf(buf, sizeof buf, "<e:%s>%s", t1, oppretty[exprop(n)]);
break;
case OTzarg: