ref: c06740c30c8ebf1e07298e14c3e70a688d12c6ca
parent: bc3a2a3b871d3126de301b51fd58c452c4ef5ead
author: Ori Bernstein <ori@eigenstate.org>
date: Wed Dec 28 17:25:26 EST 2016
Be better about unifying instead of just overwriting. In rare conditions we were clobbering the shifting up of the delayed type, which would lead to a spurious type error.
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -1391,9 +1391,7 @@
isconst = isconst && args[i]->expr.isconst;
}
}
- if (exprop(n) == Ovar)
- n->expr.isconst = decls[n->expr.did]->decl.isconst;
- else if (opispure[exprop(n)])
+ if (opispure[exprop(n)])
n->expr.isconst = isconst;
*exprconst = n->expr.isconst;
}
@@ -1930,11 +1928,14 @@
base = htget(st->seqbase, orig);
if (orig->type == Tyvar && hthas(st->delayed, orig)) {
delayed = htget(st->delayed, orig);
- if (t->type == Tyvar)
- t = delayed;
- else if (tybase(t)->type != delayed->type && !noerr)
+ if (t->type == Tyvar) {
+ /* tyvar is guaranteed to unify error-free */
+ unify(st, ctx, t, delayed);
+ t = tf(st, t);
+ } else if (tybase(t)->type != delayed->type && !noerr) {
fatal(ctx, "type %s not compatible with %s near %s\n", tystr(t),
tystr(delayed), ctxstr(st, ctx));
+ }
}
if (t->type == Tyvar) {
if (hastrait(t, traittab[Tcint]) && checktraits(t, tyint))