summaryrefslogtreecommitdiff
path: root/parse/infer.c
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2018-01-14 00:16:45 -0800
committerOri Bernstein <ori@eigenstate.org>2018-01-14 00:16:45 -0800
commit8a53929e91acf351a11ec717c726833b2c703be1 (patch)
treeab8d28c4e4f65e3a97197fc0318a835b2f367bd0 /parse/infer.c
parent3d078d5439e93a3dfc4b808ab6bf02805d455ff8 (diff)
downloadmc-8a53929e91acf351a11ec717c726833b2c703be1.tar.gz
Unify with the existing iterator.
Diffstat (limited to 'parse/infer.c')
-rw-r--r--parse/infer.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/parse/infer.c b/parse/infer.c
index 391a29d..4298eed 100644
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -607,9 +607,8 @@ tysubstmap(Tysubst *subst, Type *t, Type *orig)
{
size_t i;
- for (i = 0; i < t->ngparam; i++) {
+ for (i = 0; i < t->ngparam; i++)
substput(subst, t->gparam[i], tf(orig->arg[i]));
- }
t = tyfreshen(subst, t);
return t;
}
@@ -2384,7 +2383,9 @@ fixiter(Node *n, Type *ty, Type *base)
{
size_t i, bestidx;
int r, bestrank;
- Type *b, *t;
+ Type *b, *t, *orig;
+ Tysubst *ts;
+ Node *impl;
ty = tysearch(ty);
b = htget(seqbase, ty);
@@ -2402,8 +2403,14 @@ fixiter(Node *n, Type *ty, Type *base)
}
}
if (bestrank >= 0) {
- t = tf(impltab[bestidx]->impl.aux[0]);
- t = tyfreshen(NULL, t);
+ impl = impltab[bestidx];
+ orig = impl->impl.type;
+ t = tf(impl->impl.aux[0]);
+ ts = mksubst();
+ for (i = 0; i < ty->narg; i++)
+ substput(ts, tf(orig->arg[i]), ty->arg[i]);
+ t = tyfreshen(ts, t);
+ substfree(ts);
unify(n, t, base);
}
}