From b9268518f631ac5decc7d0039ec16963d3e536f3 Mon Sep 17 00:00:00 2001 From: TopchetoEU <36534413+TopchetoEU@users.noreply.github.com> Date: Fri, 6 Sep 2024 15:46:10 +0300 Subject: [PATCH] fix: array statements broken when empty elements --- .../me/topchetoeu/jscript/compilation/values/ArrayNode.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/me/topchetoeu/jscript/compilation/values/ArrayNode.java b/src/main/java/me/topchetoeu/jscript/compilation/values/ArrayNode.java index 4cbf300..53ba93d 100644 --- a/src/main/java/me/topchetoeu/jscript/compilation/values/ArrayNode.java +++ b/src/main/java/me/topchetoeu/jscript/compilation/values/ArrayNode.java @@ -18,11 +18,10 @@ public class ArrayNode extends Node { @Override public void compile(CompileResult target, boolean pollute) { target.add(Instruction.loadArr(statements.length)); - if (statements.length > 0) target.add(Instruction.dup(statements.length)); - for (var i = 0; i < statements.length; i++) { var el = statements[i]; if (el != null) { + target.add(Instruction.dup()); el.compile(target, true); target.add(Instruction.storeMember(i)); }