From 376f28044cf78be26f05c2230b78f23326f62ae7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= Date: Tue, 3 Jan 2023 12:55:48 +0100 Subject: [PATCH] Resolver - Fixed function handling * Since the arguments are stored in an intermediate environment, an additional scope is required --- src/resolver.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/resolver.rs b/src/resolver.rs index 4a35811..e91d193 100644 --- a/src/resolver.rs +++ b/src/resolver.rs @@ -68,8 +68,12 @@ impl ResolverState { self.declare(param); self.define(param); } + // Unlike the original Lox, function arguments and function bodies do + // not use the same environment. + self.begin_scope(); let result = body.resolve(self); self.end_scope(); + self.end_scope(); result }