summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2016-01-31 02:13:18 -0800
committerOri Bernstein <ori@eigenstate.org>2016-01-31 02:13:18 -0800
commitfb8753c942a8d06926977d221d5c89c3a867fa29 (patch)
tree0bc0f5d82f8027fd530e23f59e10122514a7240a
parentb1a3d3df704e61aa55c34c623380967f06700b41 (diff)
downloadmc-fb8753c942a8d06926977d221d5c89c3a867fa29.tar.gz
Make tysearch error-free.
-rw-r--r--parse/infer.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/parse/infer.c b/parse/infer.c
index 492049c..d531148 100644
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -436,9 +436,16 @@ static void tyresolve(Inferstate *st, Type *t)
}
}
-/* 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 @@ static Type *tf(Inferstate *st, Type *orig)
Type *t;
assert(orig != NULL);
- t = tysearch(orig);
+ t = tylookup(orig);
isgeneric = t->type == Tygeneric;
st->ingeneric += isgeneric;
tyresolve(st, t);