mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-24 02:31:13 +08:00
fix: class 声明名纳入闭包捕获,嵌套函数经 cell 读取类绑定
This commit is contained in:
@@ -400,6 +400,16 @@ impl Emitter {
|
||||
Operand::None,
|
||||
));
|
||||
}
|
||||
// 类名被外层嵌套函数捕获时,真实名 cell 同样须初始化(类元素自引用走
|
||||
// @@class_self_* 合成 cell,二者 cell_idx 不同则各发一次)。
|
||||
if let Some(&cell_idx) = ctx.captured_bindings.get(name) {
|
||||
ctx.inst(Inst::new(
|
||||
OpCode::MAKE_CELL,
|
||||
Operand::Reg(binding_reg),
|
||||
Operand::Imm(cell_idx as u16),
|
||||
Operand::None,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
if pushed_scope {
|
||||
|
||||
@@ -86,6 +86,13 @@ impl Emitter {
|
||||
out.insert(id.name.to_string());
|
||||
}
|
||||
}
|
||||
// class 名是本作用域 const 绑定:须计入 own_bindings,否则嵌套函数
|
||||
// 引用类名时捕获分析缺失 → 落符号表兜底(TDZ 误报或读父寄存器残留)。
|
||||
Statement::ClassDeclaration(cd) => {
|
||||
if let Some(id) = &cd.id {
|
||||
out.insert(id.name.to_string());
|
||||
}
|
||||
}
|
||||
// import 绑定是模块作用域 const 绑定,须计入 own_bindings 供
|
||||
// 嵌套函数 cell 捕获。
|
||||
Statement::ImportDeclaration(imp) => {
|
||||
|
||||
Reference in New Issue
Block a user