From fdac93bf4dbb01f92a0fbaeea7cc1877ea2cd68f Mon Sep 17 00:00:00 2001 From: TopchetoEU <36534413+TopchetoEU@users.noreply.github.com> Date: Fri, 20 Sep 2024 10:16:48 +0300 Subject: [PATCH] fix: scope offsets calculated incorrectly --- .../java/me/topchetoeu/jscript/compilation/scope/Scope.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/me/topchetoeu/jscript/compilation/scope/Scope.java b/src/main/java/me/topchetoeu/jscript/compilation/scope/Scope.java index bed8f93..62de6c0 100644 --- a/src/main/java/me/topchetoeu/jscript/compilation/scope/Scope.java +++ b/src/main/java/me/topchetoeu/jscript/compilation/scope/Scope.java @@ -129,7 +129,7 @@ public class Scope { var res = 0; for (var curr = parent; curr != null; curr = curr.parent) { - res += parent.locals.size(); + res += curr.locals.size(); } return res; @@ -138,7 +138,7 @@ public class Scope { var res = 0; for (var curr = this; curr != null; curr = curr.parent) { - if (curr != this) res += parent.capturables.size(); + if (curr != this) res += curr.capturables.size(); if (curr.parent == null) res += curr.localsCount(); }