summaryrefslogtreecommitdiff
path: root/parse
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2017-09-02 17:04:28 -0700
committerOri Bernstein <ori@eigenstate.org>2017-09-02 17:04:28 -0700
commita7f23ccc3e024fd71451c285d9afec55f220d8df (patch)
treedccccc119445df5c6d7bde8e077a43c3655063f4 /parse
parent290709fdfc3fa92e84f9f2bf214c6a144f24c5ee (diff)
downloadmc-a7f23ccc3e024fd71451c285d9afec55f220d8df.tar.gz
Fix export tagging of traits.
Sometimes, traits would not get tagged for export transitively.
Diffstat (limited to 'parse')
-rw-r--r--parse/export.c9
-rw-r--r--parse/infer.c15
2 files changed, 17 insertions, 7 deletions
diff --git a/parse/export.c b/parse/export.c
index 0a777e7..ee40165 100644
--- a/parse/export.c
+++ b/parse/export.c
@@ -87,12 +87,19 @@ tagtype(Stab *st, Type *t, int ingeneric, int hidelocal)
tagtype(st, t->udecls[i]->etype, ingeneric, hidelocal);
break;
case Tyname:
+ case Tygeneric:
tagreflect(t);
for (i = 0; i < t->narg; i++)
tagtype(st, t->arg[i], ingeneric, hidelocal);
- case Tygeneric:
for (i = 0; i < t->ngparam; i++)
tagtype(st, t->gparam[i], ingeneric, hidelocal);
+ for (i = 0; i < t->narg; i++)
+ tagtype(st, t->arg[i], ingeneric, hidelocal);
+ break;
+ case Typaram:
+ if (t->trneed)
+ for (i = 0; bsiter(t->trneed, &i); i++)
+ tagtrait(st, traittab[i], ingeneric, hidelocal);
break;
default:
break;
diff --git a/parse/infer.c b/parse/infer.c
index 0b0852a..9cd598f 100644
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -639,8 +639,10 @@ tf(Type *orig)
popenv(orig->env);
} else if (orig->type == Typaram) {
tt = boundtype(t);
- if (tt)
+ if (tt) {
+ tyresolve(tt);
t = tt;
+ }
}
ingeneric -= isgeneric;
return t;
@@ -869,8 +871,9 @@ tryconstrain(Type *base, Trait *tr)
ty = base;
tm = traitmap->sub[ty->type];
while (1) {
- if (ty->type == Typaram && bshas(ty->trneed, tr->uid))
- return 1;
+ if (ty->type == Typaram)
+ if (ty->trneed && bshas(ty->trneed, tr->uid))
+ return 1;
if (ty->type == Tyvar) {
if (!ty->trneed)
ty->trneed = mkbs();
@@ -1653,7 +1656,7 @@ inferexpr(Node **np, Type *ret, int *sawret)
case Odiveq: /* @a /= @a -> @a */
infersub(n, ret, sawret, &isconst);
t = type(args[0]);
- constrain(n, type(args[0]), traittab[Tcnum]);
+ constrain(n, t, traittab[Tcnum]);
isconst = args[0]->expr.isconst;
for (i = 1; i < nargs; i++) {
isconst = isconst && args[i]->expr.isconst;
@@ -1681,8 +1684,8 @@ inferexpr(Node **np, Type *ret, int *sawret)
case Obsreq: /* @a >>= @a -> @a */
infersub(n, ret, sawret, &isconst);
t = type(args[0]);
- constrain(n, type(args[0]), traittab[Tcnum]);
- constrain(n, type(args[0]), traittab[Tcint]);
+ constrain(n, t, traittab[Tcnum]);
+ constrain(n, t, traittab[Tcint]);
isconst = args[0]->expr.isconst;
for (i = 1; i < nargs; i++) {
isconst = isconst && args[i]->expr.isconst;