Skip to content

fix(json): internalize JSON.parse reviver properties - #4595

Merged
proggeramlug merged 1 commit into
PerryTS:mainfrom
andrewtdiz:codex/node-compat-json-reviver-internalize-20260605
Jun 5, 2026
Merged

fix(json): internalize JSON.parse reviver properties#4595
proggeramlug merged 1 commit into
PerryTS:mainfrom
andrewtdiz:codex/node-compat-json-reviver-internalize-20260605

Conversation

@andrewtdiz

Copy link
Copy Markdown
Contributor

Linked Issues

Closes #4588

Summary

  • Rework JSON.parse(text, reviver) to walk via holder/key internalization instead of raw object/array slots.
  • Use post-order traversal with [[Get]] re-reads, Object.keys snapshots for objects, array-length snapshots for arrays, holder this binding, and root wrapper semantics.
  • Apply reviver results through delete-or-define behavior while preserving non-configurable properties and keeping moved-GC handles refreshed across callbacks and descriptor writes.
  • Add a globals parity fixture for deletion, holes, inherited re-reads, root handling, getter abrupt completion, and non-configurable descriptor cases.

Why This Cut

This is scoped to JSON.parse reviver internalization semantics. It intentionally stays separate from JSON.parse argument coercion and broader object/array descriptor model work.

Tests

  • PASS: cargo test -q -p perry-runtime --lib json_reviver -- --nocapture
  • PASS: cargo test -q -p perry-runtime --lib json:: -- --nocapture
  • PASS: PATH=/root/.npm/_npx/bac97da9607b7ef2/node_modules/.bin:$PATH PERRY_NO_AUTO_OPTIMIZE=1 ./run_parity_tests.sh --suite node-suite --module globals --filter json-parse-reviver-internalize
  • PASS: PERRY_JSON_TAPE=1 PERRY_NO_AUTO_OPTIMIZE=1 ./target/release/perry run test-files/test_json_lazy_reviver.ts
  • PASS: PATH=/root/.npm/_npx/bac97da9607b7ef2/node_modules/.bin:$PATH node --experimental-strip-types test-parity/node-suite/globals/json-parse-reviver-internalize.ts
  • PASS: cargo check -q -p perry-codegen -p perry-runtime (existing warnings)
  • PASS: git diff --check

Current Base Check Notes

  • cargo fmt --all -- --check currently fails on crates/perry-codegen/src/expr/property_get.rs, which is outside this PR's diff and present on the rebased base.
  • ./scripts/check_file_size.sh currently fails because crates/perry-runtime/src/regex.rs is 2080 lines on the rebased base; this PR does not touch that file.

Known Limitations

  • Proxy-specific internal methods are not covered here; this uses Perry's existing object, array, prototype, accessor, and descriptor paths.
  • Array numeric accessor descriptor support remains separate; the parity fixture avoids depending on that unrelated gap.

Non-Goals

  • JSON parser/stringifier rewrite
  • JSON.parse argument ToString behavior
  • Proxy internal method parity
  • Array descriptor model rewrite

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JSON.parse reviver: implement full InternalizeJSONProperty semantics (~40 test262 fails)

2 participants