ref: 70f97fe9898b4852257a9268e6ea0592ee7e3a88
parent: 7eaed70990b148db0bebdcc218280cacff932ac4
author: Ori Bernstein <[email protected]>
date: Sat Jan 13 17:55:37 EST 2018
Clean up iterator unification.
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -2061,7 +2061,7 @@
{
size_t i, nbound;
Node **bound, *n, *pat;
- Type *t, *b;
+ Type *t, *b, *e;
n = *np;
if (!n)
@@ -2127,12 +2127,14 @@
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 @@
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();