Skip to content

[codex] Align function prototype value reads#4272

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

[codex] Align function prototype value reads#4272
proggeramlug merged 1 commit into
PerryTS:mainfrom
andrewtdiz:codex/node-compat-function-prototype-value

Conversation

@andrewtdiz
Copy link
Copy Markdown
Contributor

Summary

Addresses #2768 and #3877.

This aligns direct ordinary function .prototype value reads for local function values so codegen routes FuncRef/closure prototype reads through the runtime materialization path. That gives Object.create(Foo.prototype) and Reflect.construct(..., newTarget) an object value instead of the previous non-object result, while preserving dynamic/deleted prototype properties and generator function prototype handling.

The PR also adds a focused object parity fixture for ordinary function prototype values, assigned prototype objects, Object.create(Foo.prototype), and arrow-function absence.

Why Batched

Both issues hit the same runtime/codegen invariant: construct/proxy/object creation flows depend on newTarget.prototype or Foo.prototype being an object when an ordinary function exposes its default prototype. Keeping them together avoids splitting one semantic fix across duplicate reflect/proxy symptoms.

Validation

  • 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 function-prototype-value'
  • 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 reflect-proxy-construct'
  • Direct Node/Perry output diff for test-parity/node-suite/object/function-prototype-value.ts
  • Direct Node/Perry output diff for test-parity/node-suite/object/reflect-proxy-construct.ts
  • cargo fmt --all -- --check
  • git diff --check
  • ./scripts/check_file_size.sh

cargo build --release --quiet -p perry -p perry-runtime -p perry-stdlib passed on the code-bearing diff before the final comment-only cleanup. A later retry after that cleanup was interrupted by SIGTERM while another release job was running in a separate worktree.

Known Limitations

This intentionally keeps the cut narrow. Imported function .prototype value reads and broader inherited-property behavior through objects created from Foo.prototype are left as follow-up work; this PR fixes the local FuncRef/closure value-read tail that blocks the focused reflect/proxy construct parity fixture.

@proggeramlug proggeramlug marked this pull request as ready for review June 4, 2026 09:59
@proggeramlug proggeramlug merged commit 29424d1 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