mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-24 02:31:13 +08:00
fix: REPL 变量跨轮次丢失 —— let/const 脚本顶层写全局对象
This commit is contained in:
@@ -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(())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user