From f62ac19faca774167799d39fe0b7deaf1e0d3baa Mon Sep 17 00:00:00 2001 From: pjh456 <147148383@qq.com> Date: Sat, 6 Jun 2026 14:36:20 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20TDZ=20=E5=8F=98?= =?UTF-8?q?=E9=87=8F=E8=AF=AF=E5=86=99=E5=85=A5=E5=85=A8=E5=B1=80=E4=BD=9C?= =?UTF-8?q?=E7=94=A8=E5=9F=9F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/oxide_compiler/src/symbol_table.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/oxide_compiler/src/symbol_table.rs b/crates/oxide_compiler/src/symbol_table.rs index 24472c93..692f675c 100644 --- a/crates/oxide_compiler/src/symbol_table.rs +++ b/crates/oxide_compiler/src/symbol_table.rs @@ -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(),