fix: 块内函数声明预声明支持(Annex B 块级绑定)

This commit is contained in:
2026-08-15 23:13:26 +08:00
parent ec32e42ce5
commit 2a447b17fe
3 changed files with 166 additions and 0 deletions
+3
View File
@@ -9,6 +9,9 @@ impl Emitter {
return Ok(None);
};
ctx.push_scope();
// 函数预声明先于 lexical:`{ let g; function g(){} }` 时 lexical 的预声明
// 命中已存在的函数绑定自然报重复声明错,不被静默覆盖破坏 TDZ。
self.predeclare_block_function_declarations(&block.body, ctx);
self.predeclare_lexical_declarations(&block.body, ctx);
let mut r = None;
for s in &block.body {