Resolver - Fixed function handling

* Since the arguments are stored in an intermediate environment, an
    additional scope is required
This commit is contained in:
Emmanuel BENOîT 2023-01-03 12:55:48 +01:00
parent 5a12ce44c1
commit 376f28044c

View file

@ -68,8 +68,12 @@ impl ResolverState {
self.declare(param); self.declare(param);
self.define(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); let result = body.resolve(self);
self.end_scope(); self.end_scope();
self.end_scope();
result result
} }