Resolver - Fixed off-by-one error in resolve_local()
This commit is contained in:
parent
79a0667f34
commit
b5573cee3b
1 changed files with 2 additions and 3 deletions
|
@ -65,14 +65,13 @@ impl ResolverState {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn resolve_local(&mut self, expr: &ast::ExprNode, name: &Token) {
|
fn resolve_local(&mut self, expr: &ast::ExprNode, name: &Token) {
|
||||||
let start = self.scopes.len() - 1;
|
let mut i = self.scopes.len();
|
||||||
let mut i = start;
|
|
||||||
while i != 0 {
|
while i != 0 {
|
||||||
|
i -= 1;
|
||||||
if self.scopes[i].contains_key(&name.lexeme as &str) {
|
if self.scopes[i].contains_key(&name.lexeme as &str) {
|
||||||
self.mark_resolved(expr, self.scopes.len() - 1 - i);
|
self.mark_resolved(expr, self.scopes.len() - 1 - i);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
i -= 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue