shithub: mc

Download patch

ref: fc260ededc77024140693c31d8a3230d3fc5b75a
parent: d20ac61f136fd03b34d0ca1272760a7fa19fa2e7
author: Ori Bernstein <[email protected]>
date: Mon Aug 19 13:34:38 EDT 2013

Improve error messages with mismatched subtypes.

--- a/parse/infer.c
+++ b/parse/infer.c
@@ -573,14 +573,11 @@
     /* if the tyrank of a is 0 (ie, a raw tyvar), just unify.
      * Otherwise, match up subtypes. */
     if ((a->type == b->type || idxhacked(a, b)) && tyrank(a) != 0) {
-        for (i = 0; i < b->nsub; i++) {
-            /* types must have same arity */
-            if (i >= a->nsub)
-                fatal(ctx->line, "%s has wrong subtypes for %s near %s",
-                      tystr(a), tystr(b), ctxstr(st, ctx));
-
+        if (a->nsub != b->nsub)
+            fatal(ctx->line, "%s has wrong subtype count for %s (got %d, expected %d) near %s\n",
+                  tystr(a), tystr(b), a->nsub, b->nsub, ctxstr(st, ctx));
+        for (i = 0; i < b->nsub; i++)
             unify(st, ctx, a->sub[i], b->sub[i]);
-        }
         r = b;
     } else if (a->type != Tyvar) {
         fatal(ctx->line, "%s incompatible with %s near %s",