Skip to content

[codex] Align captured Object.assign value shape#4270

Merged
proggeramlug merged 1 commit into
PerryTS:mainfrom
andrewtdiz:codex/node-compat-object-assign-captured-value
Jun 4, 2026
Merged

[codex] Align captured Object.assign value shape#4270
proggeramlug merged 1 commit into
PerryTS:mainfrom
andrewtdiz:codex/node-compat-object-assign-captured-value

Conversation

@andrewtdiz
Copy link
Copy Markdown
Contributor

Linked issues

Summary

This PR aligns the captured Object.assign value shape with Node for the React-reconciler style pattern:

const assign = Object.assign;
assign({}, state, payload);

Current main already routes the captured call through the Object.assign alias-call rewrite, so the copy itself works. The value read still materializes as Perry's builtin sentinel, so typeof assign, assign.name, and assign.length are wrong. This keeps value reads for the already-reified Object statics on the real Object constructor closure, where the runtime has function-valued static properties installed.

It also corrects Object.assign.length to Node's value of 2 while preserving the runtime rest-argument call arity used by the assign thunk.

Why this cut

The issue is specifically about a captured Object.assign alias used by React's HostRoot update queue. The HIR receiver-collapse fix and the existing runtime static metadata share the same behavior surface, so they belong in one small object-model PR. Broader React execution and other non-reified Object static values are intentionally left out.

Tests

Added node-suite/object/captured-object-assign covering:

  • typeof Object.assign after capture
  • captured name and length
  • target identity preservation
  • multi-source copy output

Validation run locally with Node v26.3.0:

  • npm exec --yes --package=node@26 -- node --experimental-strip-types test-parity/node-suite/object/captured-object-assign.ts
  • Direct Perry-vs-Node output diff for captured-object-assign
  • PERRY_NO_AUTO_OPTIMIZE=1 npm exec --yes --package=node@26 -- bash -lc 'node --version; ./run_parity_tests.sh --suite node-suite --module object --filter captured-object-assign'
  • PERRY_NO_AUTO_OPTIMIZE=1 npm exec --yes --package=node@26 -- bash -lc 'node --version; ./run_parity_tests.sh --suite node-suite --module object --filter assign-coercion-errors'
  • cargo fmt --all -- --check
  • cargo check -p perry-hir -p perry-runtime
  • git diff --check
  • ./scripts/check_file_size.sh

Known limitations / non-goals

  • Does not attempt a full React reconciler run.
  • Does not add new runtime static values for Object methods that are not already reified on the constructor.
  • Does not change the existing Object.assign copy/descriptor/proxy behavior beyond captured value shape and length metadata.

@proggeramlug proggeramlug marked this pull request as ready for review June 4, 2026 09:59
@proggeramlug proggeramlug merged commit bab4efd into PerryTS:main Jun 4, 2026
11 checks passed
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.

2 participants