aboutsummaryrefslogtreecommitdiffstats
path: root/src/compile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/compile.cpp')
-rw-r--r--src/compile.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/compile.cpp b/src/compile.cpp
index ccde2ca..8518051 100644
--- a/src/compile.cpp
+++ b/src/compile.cpp
@@ -84,12 +84,13 @@ compile_call(CEnv& cenv, const ACall* call) throw()
static CVal
compile_def(CEnv& cenv, const ADef* def) throw()
{
- const ASymbol* const sym = def->list_ref(1)->as<const ASymbol*>();
- cenv.def(sym, def->body(), cenv.type(def->body()), NULL); // define stub first for recursion
- CVal val = resp_compile(cenv, def->body());
- if (cenv.vals.size() == 1 && cenv.type(def->body())->head()->str() != "Fn") {
+ const ASymbol* const sym = def->list_ref(1)->as<const ASymbol*>();
+ const AST* const body = def->list_ref(2);
+ cenv.def(sym, body, cenv.type(body), NULL); // define stub first for recursion
+ CVal val = resp_compile(cenv, body);
+ if (cenv.vals.size() == 1 && cenv.type(body)->head()->str() != "Fn") {
val = cenv.engine()->compileGlobal(
- cenv, cenv.type(def->body()), sym->str(), val);
+ cenv, cenv.type(body), sym->str(), val);
cenv.lock(def);
}
cenv.vals.def(sym, val);