From 1b25cc15785815b9cb6258c90d8ade00ad49add9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=88=B1=E7=89=B9=E6=AF=8F=E7=BE=8A=E9=98=9F?= Date: Tue, 30 Jun 2026 22:05:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=88=86=E6=9E=90=E6=97=B6=E8=B7=B3?= =?UTF-8?q?=E8=BF=87=E7=BB=A7=E6=89=BF=E4=BD=9C=E7=94=A8=E5=9F=9F=EF=BC=8C?= =?UTF-8?q?=E9=81=BF=E5=85=8D=E5=B0=86=E5=A4=96=E5=B1=82=20var=20=E8=AF=AF?= =?UTF-8?q?=E5=88=A4=E4=B8=BA=E5=B5=8C=E5=A5=97=E5=87=BD=E6=95=B0=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/oxide_compiler/src/compiler.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/crates/oxide_compiler/src/compiler.rs b/crates/oxide_compiler/src/compiler.rs index 3bf27e9..e1e9c96 100644 --- a/crates/oxide_compiler/src/compiler.rs +++ b/crates/oxide_compiler/src/compiler.rs @@ -700,7 +700,9 @@ impl Compiler { match expr { Expression::Identifier(ident) => { let name = ident.name.as_str(); - if nested_symbols.lookup_any_binding(name).is_some() { + // Only skip if name is in the nested function's OWN scopes (not inherited scopes[0]) + let is_local = nested_symbols.scopes.iter().skip(1).any(|s| s.bindings.contains_key(name)); + if is_local { return; } if let Some((binding, _)) = parent_ctx.scopes.symbols.lookup_any_binding(name) { @@ -719,7 +721,8 @@ impl Compiler { Expression::AssignmentExpression(ae) => { if let oxide_parser::AssignmentTarget::AssignmentTargetIdentifier(ati) = &ae.left { let name = ati.name.as_str(); - if nested_symbols.lookup_any_binding(name).is_none() { + let is_local = nested_symbols.scopes.iter().skip(1).any(|s| s.bindings.contains_key(name)); + if !is_local { if let Some((binding, _)) = parent_ctx.scopes.symbols.lookup_any_binding(name) { if !seen.contains_key(name) { let cell_idx = captures.len() as u8; @@ -745,7 +748,8 @@ impl Compiler { Expression::UpdateExpression(ue) => { if let oxide_parser::SimpleAssignmentTarget::AssignmentTargetIdentifier(ati) = &ue.argument { let name = ati.name.as_str(); - if nested_symbols.lookup_any_binding(name).is_none() { + let is_local = nested_symbols.scopes.iter().skip(1).any(|s| s.bindings.contains_key(name)); + if !is_local { if let Some((binding, _)) = parent_ctx.scopes.symbols.lookup_any_binding(name) { if !seen.contains_key(name) { let cell_idx = captures.len() as u8;