Skip to content

Commit

Permalink
Fix exception when sibling array is null
Browse files Browse the repository at this point in the history
  • Loading branch information
bblanchon committed Jul 6, 2023
1 parent 2299a25 commit 3f8bd34
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/assistant/parsingProgram.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function extractValue(prg, cfg) {
value: value[i],
parent: elementExpression,
name: makeVariableName(elementExpression),
siblings: cfg.siblings?.map((x) => x[i]),
siblings: cfg.siblings?.map((x) => (x ? x[i] : null)),
});
}
}
Expand Down
13 changes: 13 additions & 0 deletions src/assistant/parsingProgram.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,4 +410,17 @@ describe("writeDecompositionCode", function () {
"}\n"
);
});

it("null sibling array", () => {
testDescompositionCode(
[{ data: [1, 3] }, { data: [2, 4] }, { data: null }],
`for (JsonObject item : doc.as<JsonArray>()) {
int data_0 = item["data"][0]; // 1, 2, 0
int data_1 = item["data"][1]; // 3, 4, 0
}
`
);
});
});

0 comments on commit 3f8bd34

Please sign in to comment.