aboutsummaryrefslogtreecommitdiffstats
path: root/src/compile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/compile.cpp')
-rw-r--r--src/compile.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/compile.cpp b/src/compile.cpp
index 605ec40..977ab27 100644
--- a/src/compile.cpp
+++ b/src/compile.cpp
@@ -77,6 +77,11 @@ ADef::compile(CEnv& cenv)
{
cenv.def(sym(), body(), cenv.type(body()), NULL); // define stub first for recursion
CVal val = body()->compile(cenv);
+ if (cenv.vals.size() == 1 && cenv.type(body())->head()->str() != "Fn") {
+ val = cenv.engine()->compileGlobal(
+ cenv, cenv.type(body()), sym()->str(), val);
+ cenv.lock(this);
+ }
cenv.vals.def(sym(), val);
return val;
}