summaryrefslogtreecommitdiff
path: root/parse/infer.c
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2018-01-13 22:55:37 -0800
committerOri Bernstein <ori@eigenstate.org>2018-01-13 23:15:59 -0800
commit70f97fe9898b4852257a9268e6ea0592ee7e3a88 (patch)
tree3f05ec018870b4d5350c435a5247fe99afcf420b /parse/infer.c
parent7eaed70990b148db0bebdcc218280cacff932ac4 (diff)
downloadmc-70f97fe9898b4852257a9268e6ea0592ee7e3a88.tar.gz
Clean up iterator unification.
Diffstat (limited to 'parse/infer.c')
-rw-r--r--parse/infer.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/parse/infer.c b/parse/infer.c
index a98db2b..20120bd 100644
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -2061,7 +2061,7 @@ infernode(Node **np, Type *ret, int *sawret)
{
size_t i, nbound;
Node **bound, *n, *pat;
- Type *t, *b;
+ Type *t, *b, *e;
n = *np;
if (!n)
@@ -2127,12 +2127,14 @@ infernode(Node **np, Type *ret, int *sawret)
infernode(&n->iterstmt.seq, NULL, sawret);
infernode(&n->iterstmt.body, ret, sawret);
- b = mktyvar(n->loc);
- t = mktyvar(n->loc);
- htput(seqbase, t, b);
- constrain(n, type(n->iterstmt.seq), traittab[Tciter]);
- unify(n, type(n->iterstmt.seq), t);
- unify(n, type(n->iterstmt.elt), b);
+ e = type(n->iterstmt.elt);
+ t = type(n->iterstmt.seq);
+ constrain(n, t, traittab[Tciter]);
+ b = basetype(t);
+ if (b)
+ unify(n, e, b);
+ else
+ htput(seqbase, t, e);
break;
case Nmatchstmt:
infernode(&n->matchstmt.val, NULL, sawret);
@@ -2874,9 +2876,6 @@ initimpl(void)
pushenv(impl->impl.env);
ty = tf(impl->impl.type);
addtraittab(traitmap, tr, ty);
- if (tr->uid == Tciter) {
- htput(seqbase, tf(impl->impl.type), tf(impl->impl.aux[0]));
- }
popenv(impl->impl.env);
}
popstab();