fix variable shadowing not working (how was this not noticed until now??)

This commit is contained in:
Mark
2024-02-22 19:13:50 +01:00
parent 4fb84741ef
commit 05c88b7826
4 changed files with 14 additions and 8 deletions

View File

@@ -45,10 +45,10 @@ impl<L: Local> Local for Info<L> {
self.scopes.last_mut().unwrap().init_var(id, value)
}
fn get_var(&self, id: &Self::VariableIdentifier) -> Option<&Self::VariableData> {
self.scopes.iter().find_map(|l| l.get_var(id))
self.scopes.iter().rev().find_map(|l| l.get_var(id))
}
fn get_var_mut(&mut self, id: &Self::VariableIdentifier) -> Option<&mut Self::VariableData> {
self.scopes.iter_mut().find_map(|l| l.get_var_mut(id))
self.scopes.iter_mut().rev().find_map(|l| l.get_var_mut(id))
}
fn duplicate(&self) -> Self {
Self {