fix(toml): stringify special values in inline arrays correctly - #7272
Open
YoinkingFishy wants to merge 1 commit into
Open
fix(toml): stringify special values in inline arrays correctly#7272YoinkingFishy wants to merge 1 commit into
YoinkingFishy wants to merge 1 commit into
Conversation
Primitive arrays were serialized with JSON.stringify, which turned Infinity, -Infinity and NaN into null, quoted dates, and turned RegExp values into empty objects. Route all inline arrays through the per-element printer instead, matching the scalar handling already used for top-level values. Inline dates are now emitted unquoted (e.g. 1970-01-01T00:00:00.000) so they parse back into a Date instead of a string. Arrays containing null or undefined now throw a descriptive error instead of the confusing Object.keys TypeError or the generic 'Should never reach'.
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7272 +/- ##
==========================================
- Coverage 95.02% 95.02% -0.01%
==========================================
Files 618 618
Lines 51496 51505 +9
Branches 9300 9311 +11
==========================================
+ Hits 48936 48944 +8
- Misses 2021 2022 +1
Partials 539 539 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Fixes #7162.
stringifyserialized primitive arrays withJSON.stringify, which has several problems for TOML output:Infinity/-Infinity/NaNwere turned intonull(invalid TOML that fails to parse back)Datevalues were emitted as quoted ISO strings, so they parsed back as strings instead ofDatesRegExpvalues became{}Now all inline arrays are emitted element-by-element through
#printAsInlineValue, matching how the same values are serialized at the top level:Arrays containing
null/undefined(which TOML cannot represent) now throwError("Cannot stringify null or undefined values")instead of an opaqueObject.keysTypeError orError("Should never reach").Testing:
deno test --allow-read --allow-run toml/— 684 passed, 0 failed (111 ignored);deno fmt --checkanddeno lintclean on changed files.AI disclosure: this PR was prepared with the assistance of AI tooling; the change was reviewed and verified locally as described above.