aboutsummaryrefslogtreecommitdiffstats
path: root/src/compile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/compile.cpp')
-rw-r--r--src/compile.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/compile.cpp b/src/compile.cpp
index 1534263..e8baed3 100644
--- a/src/compile.cpp
+++ b/src/compile.cpp
@@ -90,7 +90,13 @@ compile_def(CEnv& cenv, const ATuple* def) throw()
const ASymbol* const sym = def->list_ref(1)->as_symbol();
const AST* const body = def->list_ref(2);
CVal val = resp_compile(cenv, body);
- cenv.def(sym, body, cenv.type(body), val);
+ if (cenv.repl && cenv.vals.topLevel(sym) && !is_form(cenv.type(sym), "Fn")) {
+ CVal global = cenv.engine()->compileGlobalSet(
+ cenv, sym->sym(), val, cenv.type(body));
+ cenv.def(sym, body, cenv.type(body), global);
+ } else {
+ cenv.def(sym, body, cenv.type(body), val);
+ }
return NULL;
}