-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve cycle checks in
JSON.stringify
(#700)
* Improve cycle checks in `JSON.stringify` 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. Thsi commit solidifies the approach to checking for cycles, by scoping cycle checks and cycle stack management to the `MapAccess` and `SeqAccess` structs. * Proper version and CHANGELOG entry * Fix typos
- Loading branch information
1 parent
de8431f
commit 6f057ea
Showing
7 changed files
with
144 additions
and
43 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
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)); |