fix: 修复 TDZ 变量误写入全局作用域问题

This commit is contained in:
爱特每羊队
2026-06-06 14:36:20 +08:00
parent bca9f8995b
commit 93517ebac3
+4 -2
View File
@@ -58,8 +58,10 @@ impl SymbolTable {
}
pub fn lookup_or_global(&mut self, name: &str, reg_for_new: u8) -> u8 {
if let Ok(reg) = self.lookup(name) {
return reg;
for scope in self.scopes.iter().rev() {
if let Some(b) = scope.get(name) {
return b.reg;
}
}
self.scopes[0].insert(
name.to_string(),