Prior to this commit, the following program will erroneously fail, with a circular dependency error:
const template = {
foo: "foo",
bar: "bar",
};
const x = [];
x.push(template);
x.push(template);
x.push(template);
x.push(template);
x.push(template);
x.push(template);
console.log(JSON.stringify(x));
The logic for testing for circular dependencies didn't correctly manage the stack state and therefore pushing the same object multiple times to an array resulted in a false-positive cycle.
Cycles can only really happen in Arrays and Objects. This commit solidifies the approach to checking for cycles, by scoping cycle checks and cycle stack management to the MapAccess and SeqAccess structs.
Checklist
[x] I've updated the relevant CHANGELOG files if necessary. Changes to javy-cli and javy-core do not require updating CHANGELOG files.
Prior to this commit, the following program will erroneously fail, with a
circular dependency
error:The logic for testing for circular dependencies didn't correctly manage the stack state and therefore pushing the same object multiple times to an array resulted in a false-positive cycle.
Cycles can only really happen in Arrays and Objects. This commit solidifies the approach to checking for cycles, by scoping cycle checks and cycle stack management to the
MapAccess
andSeqAccess
structs.Checklist
javy-cli
andjavy-core
do not require updating CHANGELOG files.