Skip to content

Commit 2bd1685

Browse files
Fix function shadowing by reversing scope traversal
1 parent 8190f1a commit 2bd1685

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/environment/environment.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,10 @@ impl<A: Clone + Debug> Environment<A> {
200200
for (func_signature, func) in &self.globals.functions {
201201
all_functions.insert(func_signature.clone(), func.clone());
202202
}
203-
for scope in self.stack.iter() {
203+
// It is necessary to traverse the scope stack from bottom to top
204+
// so that functions defined in inner scopes can shadow those
205+
// defined in outer scopes.
206+
for scope in self.stack.iter().rev() {
204207
for (func_signature, func) in &scope.functions {
205208
all_functions.insert(func_signature.clone(), func.clone());
206209
}

0 commit comments

Comments
 (0)