Skip to content

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

Merged
proggeramlug merged 1 commit into
mainfrom
merge/b44
Aug 24, 2026
Merged

fix(runtime): inherit Object prototype on class instances#8781
proggeramlug merged 1 commit into
mainfrom
merge/b44

Conversation

@proggeramlug

@proggeramlug proggeramlug commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

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 remain eligible.

The exclusion now additionally requires the class id to be unregistered, which keeps native and synthetic class ids on their existing intrinsic prototype paths:

if class_id != 0
    && !is_anon_shape_class_id(class_id)
    && !class_registry::is_class_id_registered(class_id)

Validation (on the merged result)

  • All 30 lint-job checkers pass
  • perry-runtime --lib (RUST_TEST_THREADS=1): 2674 passed, 0 failed
  • perry-codegen --lib: 1230 passed, 0 failed
  • perry-codegen --tests (all integration suites): 0 failures
  • Squashed tree verified identical to the validated tree

The PR carried its own changelog.d/ fragment. No version bump.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed inherited Object.prototype properties on class instances.
    • Restored expected default toString and valueOf behavior, including normal string conversion for class instances.

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.
@proggeramlug
proggeramlug merged commit 974c57f into main Aug 24, 2026
@proggeramlug
proggeramlug deleted the merge/b44 branch August 24, 2026 19:27
@coderabbitai

coderabbitai Bot commented Aug 24, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 9ad5f796-dd36-48cb-a4fb-822d2c2753e0

📥 Commits

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

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

📝 Walkthrough

Walkthrough

Registered ES class instances now resolve inherited Object.prototype properties such as toString and valueOf. Unregistered native and synthetic class IDs remain excluded. A changelog entry documents the fix.

Changes

Class instance prototype lookup

Layer / File(s) Summary
Prototype fallback eligibility
crates/perry-runtime/src/object/field_get_set/accessors.rs, changelog.d/8780-class-instance-object-prototype-read.md
Registered class instances can use Object.prototype property fallback. Unregistered native and synthetic class IDs remain excluded. The changelog documents the corrected toString and valueOf behavior.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch merge/b44

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.

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