summaryrefslogtreecommitdiff
path: root/parse/specialize.c
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2019-02-10 23:03:36 -0800
committerOri Bernstein <ori@eigenstate.org>2019-02-10 23:03:36 -0800
commitcc5182284db2880dcfc3b0bd61dbc6ed319bacc3 (patch)
treefdaccbef00656b0391864fc1d7ee655f2059b449 /parse/specialize.c
parent32abfabfaf95942558a590a307432b499f392ea9 (diff)
downloadmc-cc5182284db2880dcfc3b0bd61dbc6ed319bacc3.tar.gz
Pass the type envs through properly in delayed unification.
Diffstat (limited to 'parse/specialize.c')
-rw-r--r--parse/specialize.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/parse/specialize.c b/parse/specialize.c
index 006662d..becf273 100644
--- a/parse/specialize.c
+++ b/parse/specialize.c
@@ -430,6 +430,7 @@ specializenode(Node *n, Tysubst *tsmap)
case Ndecl:
r->decl.did = ndecls;
/* sym */
+ r->decl.env = n->decl.env;
r->decl.name = specializenode(n->decl.name, tsmap);
r->decl.type = tysubst(n->decl.type, tsmap);
@@ -442,19 +443,24 @@ specializenode(Node *n, Tysubst *tsmap)
putdcl(curstab(), r);
/* init */
+ pushenv(r->decl.env);
r->decl.init = specializenode(n->decl.init, tsmap);
+ popenv(r->decl.env);
lappend(&decls, &ndecls, r);
break;
case Nfunc:
r->func.scope = mkstab(1);
r->func.scope->super = curstab();
+ r->func.env = n->func.env;
pushstab(r->func.scope);
+ pushenv(r->func.env);
r->func.type = tysubst(n->func.type, tsmap);
r->func.nargs = n->func.nargs;
r->func.args = xalloc(sizeof(Node *) * n->func.nargs);
for (i = 0; i < n->func.nargs; i++)
r->func.args[i] = specializenode(n->func.args[i], tsmap);
r->func.body = specializenode(n->func.body, tsmap);
+ popenv(r->func.env);
popstab();
break;
case Nimpl: