mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-24 10:41:11 +08:00
fix: 嵌套函数删除隐式全局名后外层读取不再取残留
This commit is contained in:
@@ -50,7 +50,10 @@ impl Emitter {
|
||||
// 文档),缺失抛 ReferenceError(unresolvable)。tier 名属性由
|
||||
// GlobalDeclarationInstantiation(脚本顶层声明实例化)序言创建(仅删除后缺失);
|
||||
// 未声明名属性缺失即 unresolvable。已声明 var 不再落引擎侧镜像副本。
|
||||
if self.is_global_tier_name(ctx, name) || ctx.implicit_global_reads.contains(&var_reg) {
|
||||
// 隐式全局槽(读侧登记与写侧登记同属一个槽)同样读全局对象属性:属性是
|
||||
// 隐式全局值的唯一真源,嵌套函数内 delete 真删后外层裸读据此可见,引擎侧
|
||||
// 镜像槽不反映删除。
|
||||
if self.is_global_tier_name(ctx, name) || ctx.is_implicit_global_reg(var_reg) {
|
||||
let key_idx = ctx.add_constant(Constant::String(name.to_string()));
|
||||
ctx.inst(Inst::new(OpCode::LOAD_GLOBAL, Operand::Reg(r), Operand::Const(key_idx), Operand::None));
|
||||
} else {
|
||||
|
||||
@@ -215,9 +215,10 @@ impl Emitter {
|
||||
// var 名集 ∪ 顶层函数声明名,物化 c:true 全局属性)
|
||||
// 可删;eval 顶层 let/const 不在名集内(自身 lexical
|
||||
// 环境不可删),与非 eval 脚本自身顶层 var/函数名
|
||||
// (c:false)同保留 false。
|
||||
// (c:false)同保留 false。eval 起源随嵌套函数继承,
|
||||
// 子 ctx 内 delete 同一名同样判可删。
|
||||
ctx.is_implicit_global_reg(binding.reg)
|
||||
|| (ctx.is_eval_script && ctx.global_tier_names.contains(name))
|
||||
|| (ctx.is_eval_origin && ctx.global_tier_names.contains(name))
|
||||
} else {
|
||||
// 函数/块作用域局部绑定:非属性引用,恒 false。
|
||||
false
|
||||
|
||||
Reference in New Issue
Block a user