Skip to content

fix(runtime): honor RegExp subclass accessors before builtins - #10999

Closed
proggeramlug wants to merge 3 commits into
PerryTS:mainfrom
proggeramlug:fix/10700-regexp-subclass-getter
Closed

proggeramlug wants to merge 3 commits into
PerryTS:mainfrom
proggeramlug:fix/10700-regexp-subclass-getter

Conversation

@proggeramlug

@proggeramlug proggeramlug commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #10700.

Reflect.get now includes accessors declared on a class prototype while walking toward inherited builtins. A RegExp subclass's flags and source getters run with the original instance as this; an own data property still shadows the class getter.

Validation:

  • cargo build --profile perry-dev -p perry -p perry-runtime-static -p perry-stdlib-static
  • cargo fmt --all -- --check
  • scripts/check_file_size.sh
  • ./run_parity_tests.sh --filter test_gap_10700_regexp_subclass_getter (1/1 pass with prebuilt compiler/runtime)
  • ./run_parity_tests.sh --filter test_gap_regexp_flags_2829_2828 (1/1 pass)
  • ./run_parity_tests.sh --filter test_gap_10179_regexp_cache (1/1 pass)

Summary by CodeRabbit

  • Bug Fixes
    • Fixed RegExp subclass behavior so class-defined flags and source getters take precedence over inherited built-in accessors.
    • Ensured overridden getters receive the original subclass instance when accessed directly, through reflection, or during string replacement.
    • Preserved expected behavior when properties are shadowed by own data properties, including after those properties are removed.

@coderabbitai

coderabbitai Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 694534a9-b70d-4674-88a1-6d70f1fb8e5f

📥 Commits

Reviewing files that changed from the base of the PR and between 5b835a7 and c5d32c7.

📒 Files selected for processing (1)
  • crates/perry-runtime/src/object/descriptor_state.rs

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


📝 Walkthrough

Walkthrough

The runtime now resolves accessors declared on RegExp subclass prototypes before inherited builtin accessors. The change roots the property key, preserves own data-property shadowing, and adds regression coverage for flags, source, reflection, replacement, and deletion behavior.

Changes

RegExp subclass accessor resolution

Layer / File(s) Summary
Runtime accessor resolution
crates/perry-runtime/src/object/descriptor_state.rs
The prototype walk roots the coerced property key and resolves declared-class getters before inherited builtin getters. Own data properties continue to shadow accessors.
Regression validation
test-files/test_gap_10700_regexp_subclass_getter.ts, changelog.d/10999-regexp-subclass-getter.md
The test covers overridden flags and source getters, reflection, replacement, prototype data properties, and own-property deletion. The changelog records the fix.

Priority: ➖ Normal

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

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to c5d32

RegExp subclass flags and source reads now honor subclass accessors while preserving own-property shadowing, with regression coverage for the changed behavior. The change is merge-ready.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main runtime change: honoring RegExp subclass accessors before builtin accessors.
Description check ✅ Passed The description explains the fix, references issue #10700, states the expected behavior, and lists build, formatting, file-size, and parity-test validation. It does not use all template headings or in…
Linked Issues check ✅ Passed The change in crates/perry-runtime/src/object/descriptor_state.rs resolves declared class-prototype accessors before inherited builtin accessors. The lookup preserves own data-property shadowing. Th…
Out of Scope Changes check ✅ Passed The changes contain the accessor-resolution fix, its regression test, and a related changelog entry. The tested behavior directly supports [#10700]. No unrelated implementation or test change is shown…
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

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

Copy link
Copy Markdown
Contributor Author

Landed on main in merge train 258 (#11078, v0.5.1641), main e27f0a068a.

Carried at head c5d32c76a0. CI on the train head was fully green — 22 jobs, zero failures, the first train since the public-baseline artifact was regenerated, so no known-red line to read past.

This train was bisect-verified: after an earlier 35-PR assembly hit five gap regressions, the lowering-touching PRs were split into probes, and this set (#11070) came back with all six gap shards clean while the other half reproduced all five.

Trains rebase-merge, so commits get new SHAs and GitHub cannot mark this merged. Closed as landed.

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.

bug(regex): a RegExp subclass's flag getter is ignored — the builtin RegExp.prototype getter answers instead

1 participant