ref: 4519f3ff10c67f4f965433be4ec50e3552de276f
parent: dbf997200134ee89ad814ffe13fe20b5505227eb
author: Ori Bernstein <[email protected]>
date: Fri Jul 20 15:14:00 EDT 2012
Improve error messages.
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -185,7 +185,7 @@
while (1) {
if (!tytab[t->tid] && t->type == Tyname) {
if (!(lu = gettype(curstab(), t->name)))
- fatal(t->name->line, "Could not fixd type %s", namestr(t->name));
+ fatal(t->name->line, "Could not fixed type %s", namestr(t->name));
tytab[t->tid] = lu;
}
@@ -280,7 +280,10 @@
u = namestr(n->expr.args[0]);
else
u = opstr(exprop(n));
- t = tystr(tf(st, exprtype(n)));
+ if (exprtype(n))
+ t = tystr(tf(st, exprtype(n)));
+ else
+ t = strdup("unknown");
snprintf(buf, 512, "%s:%s", u, t);
s = strdup(buf);
free(t);
@@ -418,7 +421,7 @@
if (ft->sub[i]->type == Tyvalist)
break;
inferexpr(st, n->expr.args[i], NULL, NULL);
- unify(st, n, ft->sub[i], type(st, n->expr.args[i]));
+ unify(st, n->expr.args[0], ft->sub[i], type(st, n->expr.args[i]));
}
settype(st, n, ft->sub[0]);
}
--- a/parse/parse.h
+++ b/parse/parse.h
@@ -104,8 +104,7 @@
size_t nsub; /* For compound types */
size_t nmemb; /* for aggregate types (struct, union) */
union {
- Node *aname; /* Tyalias: alias name */
- Node *name; /* Tyname: unresolved name */
+ Node *name; /* Tyname: unresolved name. Tyalias: alias name */
Node *asize; /* array size */
char *pname; /* Typaram: name of type parameter */
Node **sdecls; /* Tystruct: decls in struct */
--- a/parse/type.c
+++ b/parse/type.c
@@ -419,7 +419,7 @@
p += namefmt(p, end - p, t->name);
break;
case Tyalias:
- p += snprintf(p, end - p, "%s", namestr(t->aname));
+ p += snprintf(p, end - p, "%s", namestr(t->name));
break;
case Tystruct: p += fmtstruct(p, end - p, t); break;
case Tyunion: p += fmtunion(p, end - p, t); break;