From 8d7939d85a27883d35d7756385b06d9b2e77e229 Mon Sep 17 00:00:00 2001 From: TopchetoEU <36534413+TopchetoEU@users.noreply.github.com> Date: Tue, 10 Dec 2024 01:09:50 +0200 Subject: [PATCH] fix: wrong index calculation --- .../me/topchetoeu/jscript/compilation/scope/VariableIndex.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/me/topchetoeu/jscript/compilation/scope/VariableIndex.java b/src/main/java/me/topchetoeu/jscript/compilation/scope/VariableIndex.java index 1eee91b..ed54ce5 100644 --- a/src/main/java/me/topchetoeu/jscript/compilation/scope/VariableIndex.java +++ b/src/main/java/me/topchetoeu/jscript/compilation/scope/VariableIndex.java @@ -39,7 +39,7 @@ public final class VariableIndex { } public final Instruction toSet(boolean keep) { switch (type) { - case CAPTURES: return Instruction.storeVar(index, keep, false); + case CAPTURES: return Instruction.storeVar(~index, keep, false); case CAPTURABLES: return Instruction.storeVar(index, keep, false); case LOCALS: return Instruction.storeVar(index, keep, false); default: throw new UnsupportedOperationException("Unknown index type " + type);