@@ -162,7 +162,7 @@ def run(self):
162162 self .run_on_new_scope (self .ast .statements , curr_scope = self .top_scope )
163163 return self .top_scope
164164
165- def run_on_new_scope (self , block : list [AstNode ], scope_stack : list [Scope ] = None ,
165+ def run_on_new_scope (self , block : list [AstNode ], parent_scopes : list [Scope ] = None ,
166166 curr_scope : Scope = None ):
167167 def enter_ident (n : AstIdent ):
168168 for s in scope_stack [::- 1 ]: # Inefficient, creates a copy!
@@ -207,8 +207,7 @@ def enter_fn_decl(fn: AstDefine):
207207 return True
208208
209209 curr_scope = curr_scope or Scope ()
210- # Can't use `or` because need to preserve reference if arg is `[]`
211- scope_stack = scope_stack if scope_stack is not None else []
210+ scope_stack = parent_scopes or []
212211 scope_stack .append (curr_scope )
213212 inner_funcs : list [tuple [FuncInfo , AstDefine ]] = []
214213 # Walk self
@@ -219,8 +218,8 @@ def enter_fn_decl(fn: AstDefine):
219218 walk_ast (block , walker )
220219 # Walk sub-functions
221220 for fn_info , fn_decl in inner_funcs :
222- fn_info .subscope = self .run_on_new_scope (fn_decl . body , scope_stack ,
223- fn_info .subscope )
221+ fn_info .subscope = self .run_on_new_scope (
222+ fn_decl . body , scope_stack , fn_info .subscope )
224223 return scope_stack .pop () # Remove current scope from stack & return it
225224
226225 def err (self , msg : str , region : StrRegion ):
0 commit comments