fix: REPL 变量跨轮次丢失 —— let/const 脚本顶层写全局对象

This commit is contained in:
2026-08-21 22:44:48 +08:00
parent cf57285ebb
commit 355230b745
4 changed files with 23 additions and 5 deletions
+1 -1
View File
@@ -428,7 +428,7 @@ fn eval_repl(code: &str, kernel: &Arc<KernelCore>, vm: &mut Vm) -> ExitCode {
}
};
let compiler = Compiler::new();
let compiler = Compiler::new().with_repl_persist(true);
let hash = compiled_module_hash(&program);
let module = match kernel.code_forge().get_or_insert_with(hash, || compiler.compile(&program)) {
Ok(m) => m,