shithub: mc

Download patch

ref: 928dd90068c3c8a65d7994e2307a5ddcbb44217a
parent: 1ad08d5fdee3b975722f692e9222da1a0126d632
author: Ori Bernstein <[email protected]>
date: Wed Oct 17 14:14:43 EDT 2012

Revert "Refactor the tf() function a little bit."
This reverts commit 62f7dc8a82a51b9b043587ee0ca52c62c7420999.

--- a/parse/infer.c
+++ b/parse/infer.c
@@ -230,9 +230,9 @@
 
     if (t->resolved)
         return;
+    t->resolved = 1;
     if (t->type == Tygeneric)
         t = tyfreshen(st, t);
-    t->resolved = 1;
     tybind(st, t);
     /* if this is a generic type, bind the params. */
     /* Walk through aggregate type members */
@@ -275,20 +275,21 @@
 
     assert(t != NULL);
     lu = NULL;
-    while (tytab[t->tid])
-        t = tytab[t->tid];
-
-    if (t->type == Tyunres) {
-        ns = curstab();
-        if (t->name->name.ns) {
-            ns = getns_str(ns, t->name->name.ns);
+    while (1) {
+        if (!tytab[t->tid] && t->type == Tyunres) {
+            ns = curstab();
+            if (t->name->name.ns) {
+                ns = getns_str(ns, t->name->name.ns);
+            }
+            if (!(lu = gettype(ns, t->name)))
+                fatal(t->name->line, "Could not resolve type %s", namestr(t->name));
+            tytab[t->tid] = lu;
         }
-        if (!(lu = gettype(ns, t->name)))
-            fatal(t->name->line, "Could not resolve type %s", namestr(t->name));
-        tytab[t->tid] = lu;
+
+        if (!tytab[t->tid])
+            break;
+        t = tytab[t->tid];
     }
-    if (t->type == Tygeneric)
-        t = tyfreshen(st, t);
     tyresolve(st, t);
     return t;
 }