shithub: mc

Download patch

ref: de1fd7052689a4c1e311eb0f0b293aecfd564896
parent: ed1f9b6de0b57d098f48030ce861311c1918c8f3
author: Ori Bernstein <[email protected]>
date: Thu Oct 11 16:10:48 EDT 2012

Don't crash when resolving types.

--- a/parse/infer.c
+++ b/parse/infer.c
@@ -231,6 +231,8 @@
     if (t->resolved)
         return;
     t->resolved = 1;
+    if (t->type == Tygeneric)
+        t = tyspecialize(st, t);
     tybind(st, t);
     /* if this is a generic type, bind the params. */
     /* Walk through aggregate type members */
@@ -542,11 +544,6 @@
         b = t;
     }
 
-    if (a->type == Tygeneric)
-        a = tyspecialize(st, a);
-    if (b->type == Tygeneric)
-        b = tyspecialize(st, b);
-
     r = NULL;
     if (a->type == Tyvar) {
         tytab[a->tid] = b;
@@ -1012,8 +1009,7 @@
     Type *t;
 
     t = tf(st, decltype(n));
-    if (t->type == Tygeneric) {
-        t = tyspecialize(st, t);
+    if (decltype(n)->type == Tygeneric) {
         unifyparams(st, n, t, decltype(n));
     }
     settype(st, n, t);