shithub: mc

Download patch

ref: 82c7706dac42e23b8ceaf66894bce536a5e3f231
parent: 1c52c3c30241558dcc6bf01a618528cfe8f552b2
author: Ori Bernstein <[email protected]>
date: Sun Dec 29 19:48:42 EST 2013

Fix unification of sequence types.

    We shoudl be unifying them with an index hack, which is the only
    way to guarantee that t->sub[0] will be present.

--- a/parse/infer.c
+++ b/parse/infer.c
@@ -1264,6 +1264,7 @@
     Node *s;
     size_t nbound;
     Node **bound;
+    Type *t;
 
     if (!n)
         return;
@@ -1328,8 +1329,10 @@
             infernode(st, n->iterstmt.seq, NULL, sawret);
             infernode(st, n->iterstmt.body, ret, sawret);
 
+            t = mktyidxhack(n->line, mktyvar(n->line));
             constrain(st, n, type(st, n->iterstmt.seq), cstrtab[Tcidx]);
-            unify(st, n, type(st, n->iterstmt.elt), type(st, n->iterstmt.seq)->sub[0]);
+            unify(st, n, type(st, n->iterstmt.seq), t);
+            unify(st, n, type(st, n->iterstmt.elt), t->sub[0]);
             break;
         case Nmatchstmt:
             infernode(st, n->matchstmt.val, NULL, sawret);