Skip to content

fix(runtime): inherit Object prototype on class instances - #8780

Closed
proggeramlug wants to merge 2 commits into
mainfrom
codex/class-object-prototype-read
Closed

fix(runtime): inherit Object prototype on class instances#8780
proggeramlug wants to merge 2 commits into
mainfrom
codex/class-object-prototype-read

Conversation

@proggeramlug

@proggeramlug proggeramlug commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Summary

  • allow registered JavaScript class instances to use the ordinary Object.prototype read fallback after class methods/accessors miss
  • keep unregistered native and synthetic class IDs on their existing intrinsic prototype paths
  • restore String(new C()) and other inherited Object.prototype reads

Validation

  • BASE_SHA=origin/main scripts/run_lint_gates.sh (all 55 gates passed)
  • cargo check -p perry-runtime
  • release-mode test_gap_string_coercion_tostring parity against Node (pass)
  • release-mode test_gap_class_extends_function_static parity against Node with PR fix(runtime): materialize ordinary parent prototypes #8768 applied (pass)

Summary by CodeRabbit

  • Bug Fixes

    • Fixed inherited Object.prototype property access for declared class instances.
    • Restored correct default toString and valueOf behavior.
    • Improved ordinary string coercion for class instances.
  • Documentation

    • Added a changelog entry describing the corrected prototype property behavior.

@coderabbitai

coderabbitai Bot commented Aug 24, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 8ec677d2-794c-4d6b-abe2-51c865d61343

📥 Commits

Reviewing files that changed from the base of the PR and between 8e1367b and 046dae6.

📒 Files selected for processing (2)
  • changelog.d/8780-class-instance-object-prototype-read.md
  • crates/perry-runtime/src/object/field_get_set/accessors.rs

Included review availability: Your plan provides up to 8 included reviews per hour; 4 remain after this review.


📝 Walkthrough

Walkthrough

The runtime now permits registered ES class instances to read inherited Object.prototype properties. The changelog documents restored default toString, valueOf, and string coercion behavior.

Changes

Class instance prototype resolution

Layer / File(s) Summary
Restore Object.prototype fallback
crates/perry-runtime/src/object/field_get_set/accessors.rs, changelog.d/8780-class-instance-object-prototype-read.md
Registered ES class instances can use Object.prototype fallback lookup. Unregistered native and synthetic class IDs remain excluded. The changelog records the corrected property reads and string coercion behavior.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 046da

This localized runtime change restores inherited Object.prototype behavior for registered class instances while preserving existing paths for other class IDs. The listed validation passes, and no actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. (1 skipped: 1 unsupported.) Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the runtime change to Object.prototype inheritance for class instances.
Description check ✅ Passed The description explains the behavior change and provides concrete validation results, but omits several template headings and checklist items.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/class-object-prototype-read

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

proggeramlug added a commit that referenced this pull request Aug 24, 2026
Lands #8780.

A registered ES class instance whose class methods and accessors all
missed was excluded from the ordinary Object.prototype read fallback, so
inherited reads -- `String(new C())` among them -- failed. Declared class
instances do end their implicit prototype chain at Object.prototype, and
their own methods are consulted before this fallback runs, so a miss must
stay eligible.

The exclusion now also requires the class id to be unregistered, keeping
native and synthetic class ids on their existing intrinsic prototype
paths.

No version bump.

Co-authored-by: Ralph Küpper <ralph@skelpo.com>
@proggeramlug

Copy link
Copy Markdown
Contributor Author

Landed on main via the PR above.

Validated on the merged result: all 30 lint checkers, runtime 2674/0 at RUST_TEST_THREADS=1, codegen 1230/0, all codegen integration suites clean. Thanks — and thanks for carrying the changelog fragment.

@proggeramlug
proggeramlug deleted the codex/class-object-prototype-read branch August 25, 2026 06:20
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.

1 participant