summaryrefslogtreecommitdiff
path: root/parse
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-04-30 00:04:40 -0700
committerOri Bernstein <ori@eigenstate.org>2015-04-30 00:04:40 -0700
commit22858f62888f54dc29f431b2aa194edcd9dfec0d (patch)
tree5ef792f893244229b2969a6f751d34cde09a8a20 /parse
parent8d76103efae5aa0c028fc036c05b73b85878a781 (diff)
downloadmc-22858f62888f54dc29f431b2aa194edcd9dfec0d.tar.gz
Improve error messages for membership failures.
Diffstat (limited to 'parse')
-rw-r--r--parse/infer.c11
-rw-r--r--parse/util.c2
2 files changed, 10 insertions, 3 deletions
diff --git a/parse/infer.c b/parse/infer.c
index 576ac3f..f8403a3 100644
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -178,6 +178,9 @@ static char *ctxstr(Inferstate *st, Node *n)
else
snprintf(buf, sizeof buf, "<sl:%s>[<e1%s>:<e2:%s>]", t1, t2, t3);
break;
+ case Omemb:
+ snprintf(buf, sizeof buf, "<%s>.%s", t1, namestr(args[1]));
+ break;
default:
snprintf(buf, sizeof buf, "%s:%s", d, t);
break;
@@ -1779,8 +1782,12 @@ static void infercompn(Inferstate *st, Node *n)
} else {
if (tybase(t)->type == Typtr)
t = tybase(tf(st, t->sub[0]));
- if (tybase(t)->type != Tystruct)
- fatal(n, "type %s does not support member operators near %s", tystr(t), ctxstr(st, n));
+ if (tybase(t)->type != Tystruct) {
+ if (tybase(t)->type == Tyvar)
+ fatal(n, "underspecified type defined on %s:%d used near %s", fname(t->loc), lnum(t->loc), ctxstr(st, n));
+ else
+ fatal(n, "type %s does not support member operators near %s", tystr(t), ctxstr(st, n));
+ }
nl = t->sdecls;
for (i = 0; i < t->nmemb; i++) {
if (!strcmp(namestr(memb), declname(nl[i]))) {
diff --git a/parse/util.c b/parse/util.c
index 9b3b29e..fb0e316 100644
--- a/parse/util.c
+++ b/parse/util.c
@@ -85,7 +85,7 @@ void lfatal(Srcloc l, char *msg, ...)
void lfatalv(Srcloc l, char *msg, va_list ap)
{
- fprintf(stdout, "%s:%d: ", file->file.files[l.file], l.line);
+ fprintf(stdout, "%s:%d: ", fname(l), lnum(l));
vfprintf(stdout, msg, ap);
fprintf(stdout, "\n");
exit(1);