fix: serialize Temporal values referenced more than once in uneval#165
Open
greymoth-jp wants to merge 1 commit into
Open
fix: serialize Temporal values referenced more than once in uneval#165greymoth-jp wants to merge 1 commit into
greymoth-jp wants to merge 1 commit into
Conversation
uneval's inline value format handles Temporal types, but the reference
format used for values that appear more than once (or in a cycle) had no
Temporal case, so it fell through to the plain-object branch and emitted
{}. A repeated Temporal value was therefore silently turned into an empty
object, while stringify round-tripped the same value correctly.
Mirror the Temporal cases into the reference format and add a repetition
fixture.
🦋 Changeset detectedLatest commit: efcb0be The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
unevalhas two code paths: an inline value format, and a reference format used when a value appears more than once or inside a cycle (the value is hoisted into a function parameter so the references can share identity).The inline format handles the eight
Temporal.*types, but the reference format never got a matching case, so a repeated Temporal value falls through to the plain-object branch and is emitted as{}. It is silently lost:stringifyround-trips the same input correctly ([[1,1],["Temporal.Instant","1999-09-29T05:30:00Z"]]), so the two serializers disagreed on a repeated Temporal value.This mirrors the existing inline Temporal case into the reference switch and adds a repetition fixture. Reverting only the
uneval.jschange fails the newuneval: repetitioncase while thestringify/parse/unflattenchecks stay green, which isolates the bug touneval.