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
+4
View File
@@ -98,6 +98,10 @@ impl Emitter {
if ctx.is_global_scope && matches!(kind, VariableDeclarationKind::Var) {
self.emit_global_prop_write(name, src_reg, ctx);
}
// REPL 持久模式:let/const 也写全局对象属性,使跨轮次读取可见。
if ctx.repl_persist && ctx.is_global_scope && !matches!(kind, VariableDeclarationKind::Var) {
self.emit_global_prop_write(name, src_reg, ctx);
}
Ok(())
}