ref: 6eea4ad525d048ac253d7f06de673b68d0bb9add
parent: b655561599c0be143c634e0c47a1a3ff1d5f76d6
author: Ori Bernstein <[email protected]>
date: Fri Jan 6 18:55:53 EST 2012
Fix unification of compound types with tyvars.
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -133,6 +133,12 @@
}
}
+void breakhere()
+{
+ volatile int a;
+ a++;
+}
+
static Type *unify(Node *ctx, Type *a, Type *b)
{
Type *t;
@@ -147,22 +153,27 @@
b = t;
}
+ breakhere();
matchcstrs(ctx, a, b);
- if (a->type != b->type && a->type != Tyvar)
- fatal(ctx->line, "%s incompatible with %s near %s", tystr(a), tystr(b), ctxstr(ctx));
-
- tytab[a->tid] = b;
- for (i = 0; i < b->nsub; i++) {
- /* types must have same arity */
- if (i >= a->nsub)
+ if (a->type != b->type) {
+ if (a->type == Tyvar)
+ tytab[a->tid] = b;
+ else
fatal(ctx->line, "%s incompatible with %s near %s", tystr(a), tystr(b), ctxstr(ctx));
+ return b;
+ } else {
+ for (i = 0; i < b->nsub; i++) {
+ /* types must have same arity */
+ if (i >= a->nsub)
+ fatal(ctx->line, "%s incompatible with %s near %s", tystr(a), tystr(b), ctxstr(ctx));
- /* FIXME: recurse properly.
- matchcstrs(ctx, a, b);
- unify(ctx, a->sub[i], b->sub[i]);
- */
+ /* FIXME: recurse properly.
+ matchcstrs(ctx, a, b);
+ unify(ctx, a->sub[i], b->sub[i]);
+ */
+ }
+ return b;
}
- return b;
}
static void unifycall(Node *n)