ref: a8ab64015b9419f0a32c1162c2442c27163dff66
parent: be26bedd4883ebc3679ece90df4ba508fee87f8e
author: Ori Bernstein <ori@eigenstate.org>
date: Sat Feb 9 16:48:50 EST 2019
Work towards removing the streq check.
--- a/parse/gram.y
+++ b/parse/gram.y
@@ -1197,7 +1197,8 @@
for (i = 0; i < nts; i++) {
switch (ty->type) {
case Typaram:
- if (tyeq(ty, ts[i]->param))
+ assert(ts[i]->param->type == Typaram);
+ if (streq(ty->pname, ts[i]->param->pname))
lappend(&ty->spec, &ty->nspec, ts[i]);
break;
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -647,6 +647,8 @@
ingeneric += isgeneric;
pushenv(orig->env);
tyresolve(t);
+ if ((tt = boundtype(t)) != NULL)
+ t = tt;
popenv(orig->env);
/* If this is an instantiation of a generic type, we want the params to
* match the instantiation */
--- a/parse/type.c
+++ b/parse/type.c
@@ -792,7 +792,7 @@
int
tyeq_rec(Type *a, Type *b, Bitset *avisited, Bitset *bvisited, int search)
{
- Type *x, *y;
+ Type *x, *y, *t;
Typair p;
size_t i;
int ret;
@@ -802,6 +802,10 @@
if (search) {
a = tysearch(a);
b = tysearch(b);
+ if ((t = boundtype(a)) != NULL)
+ a = tysearch(t);
+ if ((t = boundtype(b)) != NULL)
+ b = tysearch(t);
}
if (a->type != b->type)
return 0;
@@ -829,7 +833,9 @@
switch (a->type) {
case Typaram:
- ret = streq(a->pname, b->pname);
+ ret = (a == b);
+ /* FIXME: this streq check needs to go */
+ ret = ret || streq(a->pname, b->pname);
break;
case Tyvar:
if (a->tid != b->tid)