fix: class 类名绑定 TDZ 与 const 语义(extends 引用类名抛 ReferenceError,类构建后初始化绑定)

This commit is contained in:
2026-08-12 15:37:58 +08:00
parent 5d3b5d055a
commit 621956114c
2 changed files with 56 additions and 6 deletions
@@ -26,8 +26,9 @@ impl Emitter {
reg
}
};
ctx.init_var(&name);
let ctor_reg = self.emit_class(class, ctx)?;
// 类名绑定在 emit_class_with_binding 内于 extends 求值后初始化:
// 先声明未初始化绑定(TDZ),extends 引用类名按规范抛 ReferenceError。
let ctor_reg = self.emit_class_with_binding(class, ctx, Some(var_reg))?;
if let Some(&cell_idx) = ctx.captured_bindings.get(&name) {
ctx.inst(Inst::new(
OpCode::MAKE_CELL,