shithub: mc

Download patch

ref: cb804dc4af19cad9ba86a55aa5cc8b3c1a9a4159
parent: 3cacd3499c4b91c972d1e2daede8a9c8e3efe247
author: Ori Bernstein <ori@eigenstate.org>
date: Tue Feb 11 06:11:25 EST 2014

Improve error message formatting.

--- a/parse/infer.c
+++ b/parse/infer.c
@@ -546,7 +546,7 @@
 {
     size_t i, n;
     char *sep;
-    char buf[1024];
+    char traitbuf[1024], abuf[1024], bbuf[1024];
 
     if (b->type == Tyvar) {
         /* make sure that if a = b, both have same traits */
@@ -562,10 +562,12 @@
             n = 0;
             for (i = 0; bsiter(a->traits, &i); i++) {
                 if (!bshas(b->traits, i))
-                    n += snprintf(buf + n, sizeof(buf) - n, "%s%s", sep, namestr(traittab[i]->name));
+                    n += snprintf(traitbuf + n, sizeof(traitbuf) - n, "%s%s", sep, namestr(traittab[i]->name));
                 sep = ",";
             }
-            fatal(ctx->line, "%s missing constraints %s for %s near %s", tystr(b), buf, tystr(a), ctxstr(st, ctx));
+            tyfmt(abuf, sizeof abuf, a);
+            tyfmt(bbuf, sizeof bbuf, b);
+            fatal(ctx->line, "%s missing traits %s for %s near %s", bbuf, traitbuf, abuf, ctxstr(st, ctx));
         }
     }
 }