Skip to content

Commit 3f8bd34

Browse files
committed
Fix exception when sibling array is null
1 parent 2299a25 commit 3f8bd34

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/assistant/parsingProgram.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function extractValue(prg, cfg) {
4646
value: value[i],
4747
parent: elementExpression,
4848
name: makeVariableName(elementExpression),
49-
siblings: cfg.siblings?.map((x) => x[i]),
49+
siblings: cfg.siblings?.map((x) => (x ? x[i] : null)),
5050
});
5151
}
5252
}

src/assistant/parsingProgram.spec.js

+13
Original file line numberDiff line numberDiff line change
@@ -410,4 +410,17 @@ describe("writeDecompositionCode", function () {
410410
"}\n"
411411
);
412412
});
413+
414+
it("null sibling array", () => {
415+
testDescompositionCode(
416+
[{ data: [1, 3] }, { data: [2, 4] }, { data: null }],
417+
`for (JsonObject item : doc.as<JsonArray>()) {
418+
419+
int data_0 = item["data"][0]; // 1, 2, 0
420+
int data_1 = item["data"][1]; // 3, 4, 0
421+
422+
}
423+
`
424+
);
425+
});
413426
});

0 commit comments

Comments
 (0)