summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2019-02-09 21:48:50 -0800
committerOri Bernstein <ori@eigenstate.org>2019-02-09 21:48:50 -0800
commita8ab64015b9419f0a32c1162c2442c27163dff66 (patch)
tree391e7008d65ec9b2751ce51d29fa3e1abe7606fb
parentbe26bedd4883ebc3679ece90df4ba508fee87f8e (diff)
downloadmc-a8ab64015b9419f0a32c1162c2442c27163dff66.tar.gz
Work towards removing the streq check.
-rw-r--r--parse/gram.y3
-rw-r--r--parse/infer.c2
-rw-r--r--parse/type.c10
3 files changed, 12 insertions, 3 deletions
diff --git a/parse/gram.y b/parse/gram.y
index 749d7a5..bd54217 100644
--- a/parse/gram.y
+++ b/parse/gram.y
@@ -1197,7 +1197,8 @@ setwith(Type *ty, Traitspec **ts, size_t nts)
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;
diff --git a/parse/infer.c b/parse/infer.c
index f181107..35146ec 100644
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -647,6 +647,8 @@ tf(Type *orig)
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 */
diff --git a/parse/type.c b/parse/type.c
index a0c2855..4f12b24 100644
--- a/parse/type.c
+++ b/parse/type.c
@@ -792,7 +792,7 @@ equate(int32_t ta, int32_t tb)
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 @@ tyeq_rec(Type *a, Type *b, Bitset *avisited, Bitset *bvisited, int search)
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 @@ tyeq_rec(Type *a, Type *b, Bitset *avisited, Bitset *bvisited, int search)
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)