fix: allow_missing_commas: false was ignored for array elements - #87
Merged
Conversation
Array parsing never consulted `allow_missing_commas`, so strict parsing accepted invalid JSON like `[1 2]` and `[01]`. Now array elements error with `ExpectedComma` the same way object properties do. Closes #84
- keep reporting `Unexpected word` for words in arrays, which are never valid elements regardless of `allow_missing_commas` - debug assert the previous value was consumed in `scan_array_comma` - more tests: cst, unterminated arrays, comments on the serde path and arrays that are still valid when missing commas are not allowed
1 task
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Array parsing never consulted
allow_missing_commas, so strict parsing accepted invalid JSON like[1 2]and[01](the latter scans as two numbers). Object properties already handled this—now array elements do too, erroring withExpectedCommaat the position right after the previous element.The fix is in both parser implementations, which covers all four entry points:
parse_to_ast::parse_array— also coverscst::CstRootNode::parseJsoncParser::scan_array_comma— the shared path forparse_to_valueandparse_to_serde_valueA word in an array (
[1 a ]) still reportsUnexpected wordrather than a missing comma, since a word is never a valid array element regardless of the option.Closes #84