summaryrefslogtreecommitdiff
path: root/parse/type.c
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2019-03-03 22:32:07 -0800
committerOri Bernstein <ori@eigenstate.org>2019-03-03 22:32:07 -0800
commitd51d40bc1674f5845dab709096be84a4e5c51b2b (patch)
treea1d48da740c90a972506b46f1dfe459330ce29a8 /parse/type.c
parenta68e92f1e80f262e04d6e6c1d27af80199afbdc0 (diff)
downloadmc-d51d40bc1674f5845dab709096be84a4e5c51b2b.tar.gz
Give traits the necessary env.
Diffstat (limited to 'parse/type.c')
-rw-r--r--parse/type.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/parse/type.c b/parse/type.c
index 62d4a5e..4d8c96b 100644
--- a/parse/type.c
+++ b/parse/type.c
@@ -162,6 +162,7 @@ mktrait(Srcloc loc, Node *name, Type *param,
int isproto)
{
Trait *t;
+ size_t i;
t = zalloc(sizeof(Trait));
t->uid = ntraittab++;
@@ -174,9 +175,19 @@ mktrait(Srcloc loc, Node *name, Type *param,
t->proto = proto;
t->nproto = nproto;
t->aux = aux;
+ t->env = mkenv();
t->naux = naux;
t->isproto = isproto;
+ bindtype(t->env, param);
+ for (i = 0; i < naux; i++)
+ bindtype(t->env, aux[i]);
+
+ for (i = 0; i < nproto; i++)
+ if (proto[i]->decl.env)
+ proto[i]->decl.env->super = t->env;
+
+
traittab = xrealloc(traittab, ntraittab * sizeof(Trait *));
traittab[t->uid] = t;
return t;