From b5573cee3ba07e4a9cbd953f4b52b40f18f522fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= Date: Thu, 5 Jan 2023 07:06:27 +0100 Subject: [PATCH] Resolver - Fixed off-by-one error in resolve_local() --- src/resolver.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/resolver.rs b/src/resolver.rs index d15b3df..0532c3d 100644 --- a/src/resolver.rs +++ b/src/resolver.rs @@ -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; } }