shithub: mc

Download patch

ref: bf3f933ccc20a959ec0b29e6517e19db88bfc641
parent: b1e6e521c437f1180e581e0559d437b4a4660d58
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);