ref: ea3ae1c8e5d7daf59061e0fc194b1f0ad5ba1609
parent: fb736dc5368eaa1b06d7e3c1d033deb1ba755fbb
author: Ori Bernstein <[email protected]>
date: Sun Nov 30 16:05:16 EST 2014
Fix a few type errors. Indexing should require the lhs to be indexable.
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -1356,6 +1356,7 @@
infersub(st, n, ret, sawret, &isconst);
t = mktyidxhack(n->loc, mktyvar(n->loc));
unify(st, n, type(st, args[0]), t);
+ constrain(st, n, type(st, args[0]), traittab[Tcidx]);
constrain(st, n, type(st, args[1]), traittab[Tcint]);
settype(st, n, t->sub[0]);
break;
@@ -1561,7 +1562,10 @@
k = htkeys(s->ty, &n);
for (i = 0; i < n; i++) {
- t = tysearch(gettype(s, k[i]));
+ t = gettype(s, k[i]);
+ if (!t)
+ fatal(k[i], "undefined type %s", namestr(k[i]));
+ t = tysearch(t);
updatetype(s, k[i], t);
}
free(k);