Resolver - Fixed off-by-one error in resolve_local()

This commit is contained in:
Emmanuel BENOîT 2023-01-05 07:06:27 +01:00
parent 79a0667f34
commit b5573cee3b

View file

@ -65,14 +65,13 @@ impl ResolverState {
}
fn resolve_local(&mut self, expr: &ast::ExprNode, name: &Token) {
let start = self.scopes.len() - 1;
let mut i = start;
let mut i = self.scopes.len();
while i != 0 {
i -= 1;
if self.scopes[i].contains_key(&name.lexeme as &str) {
self.mark_resolved(expr, self.scopes.len() - 1 - i);
return;
}
i -= 1;
}
}