shithub: mc

Download patch

ref: dfa5608bf26c5c5ad6ffea8c18392479ae353ded
parent: cb693d6d5d0f10028a65f97ca8cbd2d7de814c2b
author: Ori Bernstein <[email protected]>
date: Fri Sep 13 09:02:29 EDT 2013

Fix up Oucon to infer properly when the type is generic.

--- a/parse/infer.c
+++ b/parse/infer.c
@@ -1057,6 +1057,7 @@
         case Oucon:
             uc = uconresolve(st, n);
             t = tyfreshen(st, tf(st, uc->utype));
+            uc = tybase(t)->udecls[uc->id];
             if (uc->etype)
                 unify(st, n, uc->etype, type(st, args[1]));
             settype(st, n, delayed(st, t));
@@ -1254,13 +1255,13 @@
         tyflt = mktype(-1, Tyfloat64);
 
     t = tysearch(st, t);
+    if (hthas(st->delayed, t))
+        t = htget(st->delayed, t);
     if (t->type == Tyvar) {
         if (hascstr(t, cstrtab[Tcint]) && cstrcheck(t, tyint))
             return tyint;
         if (hascstr(t, cstrtab[Tcfloat]) && cstrcheck(t, tyflt))
             return tyflt;
-        if (hthas(st->delayed, t))
-            return htget(st->delayed, t);
     } else if (!t->fixed) {
         t->fixed = 1;
         if (t->type == Tyarray) {