fix: class 声明名纳入闭包捕获,嵌套函数经 cell 读取类绑定

This commit is contained in:
2026-08-16 12:34:03 +08:00
parent bbc09a8208
commit 5086e15b66
2 changed files with 17 additions and 0 deletions
+7
View File
@@ -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) => {