fix: compare JSON values structurally in equality keywords - #132
Open
fitchmultz wants to merge 2 commits into
Open
fitchmultz wants to merge 2 commits into
fitchmultz wants to merge 2 commits into
Conversation
Treat null-prototype objects as plain member maps so literal names stay data instead of falling through to host-object comparison.
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.
Summary
Use one small internal comparison utility for
enum,const, anduniqueItems. It compares JSON arrays in order and JSON objects by their own members regardless of insertion order, treating names such astoString,valueOf, andconstructoras data. The existing comparator remains responsible for non-JSON host values such as dates, regular expressions, and custom class instances. No dependency or public API changes.enumcurrently compares serialized objects, so{ a: 1, b: 2 }fails an enum containing{ b: 2, a: 1 }. Directly reusing the existing comparator would introduce failures for ordinary JSON member names. The same comparator already makesconstthrow for{"toString":"label"}and{"valueOf":1}, and makesuniqueItemsmiss duplicate nested objects with an object-valuedconstructormember. The tests reproduce those defects before the change.This follows the JSON instance equality contract in Core §4.2.2, used by enum and const and uniqueItems.
Verification
Final head
fcdaf20b7060898948538715ddd584cac9b49817, based directly on current upstream main65578c185fc324ebf8fcc8f6e654e85cbfab4da8. Rechecked September 21 with Node 24.21.0 and pnpm 10.34.5 using the frozen lockfile.test:unit: 1,037 passing, 3 pending.test:spec: 7,513 passing, 9 pending, with existing exclusions unchanged.attwreports no problems. The same 22 focused controls pass against each built runtime entrypoint.constanduniqueItemsremain passing, including dates, regular expressions, boxed numbers, custom value objects, undefined-valued members, and NaN.Upstream CI for the final head requires maintainer approval (
action_required). Local results above are not an upstream CI-success claim.This is a focused equality correction, not a claim of complete JSON Schema conformance. Generated distributions are validated locally and excluded from this source-only change.