shithub: mc

Download patch

ref: 57114efd8d6aadc94466e0a8ff26fa613d9c3e8f
parent: ceded833e958aa9f7c0c0642f09cd7942b02158b
author: Ori Bernstein <[email protected]>
date: Thu Oct 18 12:04:34 EDT 2012

Don't bail early in tyfreshen()

    Because structs aren't generics, and have no subs, we
    were returning them instead of trying to freshen them.

--- a/parse/infer.c
+++ b/parse/infer.c
@@ -124,9 +124,10 @@
     Type *ret;
     size_t i;
 
+    st->ingeneric++;
     t = tf(st, t);
-    if (t->type != Typaram && t->nsub == 0)
-        return t;
+    st->ingeneric--;
+
     switch (t->type) {
         case Typaram:
             if (hthas(ht, t->pname))
@@ -149,9 +150,13 @@
             die("Freshening unions is not yet implemented");
             break;
         default:
-            ret = tydup(t);
-            for (i = 0; i < t->nsub; i++)
-                ret->sub[i] = tyspecialize(st, ht, t->sub[i]);
+            if (t->nsub > 0) {
+                ret = tydup(t);
+                for (i = 0; i < t->nsub; i++)
+                    ret->sub[i] = tyspecialize(st, ht, t->sub[i]);
+            } else {
+                ret = t;
+            }
             break;
     }
     return ret;