fix: TDZ 写与 const 赋值检查补全(含闭包捕获路径)

This commit is contained in:
2026-08-15 21:55:43 +08:00
parent 2669967967
commit 07ea7e6d4f
8 changed files with 224 additions and 16 deletions
@@ -466,6 +466,9 @@ impl Emitter {
fn emit_identifier_update_static(
&self, name: &str, update: &oxide_parser::UpdateExpression, ctx: &mut CompileCtx,
) -> Result<u32, String> {
// 自增/自减先解析赋值引用:TDZ 绑定抛 ReferenceError;const 抛 TypeError(编译期拦截)。
self.emit_identifier_tdz_guard(name, ctx)?;
self.emit_const_write_guard(name, ctx)?;
let uv_idx = ctx.current_upvalue_captures.iter().position(|u| u.name == name);
let captured_cell = ctx.captured_bindings.get(name).copied();
// 循环 update 段:被捕获绑定走寄存器 INC/DEC(C 风格 for 每迭代 fresh,