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);