shithub: mc

Download patch

ref: fb8753c942a8d06926977d221d5c89c3a867fa29
parent: b1a3d3df704e61aa55c34c623380967f06700b41
author: Ori Bernstein <ori@eigenstate.org>
date: Sat Jan 30 21:13:18 EST 2016

Make tysearch error-free.

--- a/parse/infer.c
+++ b/parse/infer.c
@@ -436,9 +436,16 @@
 	}
 }
 
-/* Look up the best type to date in the unification table, returning it */
 Type *tysearch(Type *t)
 {
+	while (tytab[t->tid])
+		t = tytab[t->tid];
+	return t;
+}
+
+/* Look up the best type to date in the unification table, returning it */
+static Type *tylookup(Type *t)
+{
 	Type *lu;
 	Stab *ns;
 
@@ -498,7 +505,7 @@
 	Type *t;
 
 	assert(orig != NULL);
-	t = tysearch(orig);
+	t = tylookup(orig);
 	isgeneric = t->type == Tygeneric;
 	st->ingeneric += isgeneric;
 	tyresolve(st, t);