fix: 顶层受限全局名 lexical 声明编译期拒绝——let/const undefined|NaN|Infinity 撞 GDI 三常量 SyntaxError

This commit is contained in:
2026-09-12 22:45:24 +00:00
parent 41a3aef29e
commit 6aff1101f3
6 changed files with 224 additions and 22 deletions
+2 -1
View File
@@ -12,7 +12,8 @@ impl Emitter {
// 函数预声明先于 lexical:`{ let g; function g(){} }` 时 lexical 的预声明
// 命中已存在的函数绑定自然报重复声明错,不被静默覆盖破坏 TDZ。
self.predeclare_block_function_declarations(&block.body, ctx);
self.predeclare_lexical_declarations(&block.body, ctx);
// 块 lexical 声明是局部绑定:不做受限全局名检查(重复声明错在 emit 期报)。
let _ = self.predeclare_lexical_declarations(&block.body, ctx, false);
let mut r = None;
for s in &block.body {
if let Some(rr) = self.emit_statement(s, ctx)? {