Skip to content

fix(hir): preserve class self brand through private updates - #9126

Merged
proggeramlug merged 1 commit into
PerryTS:mainfrom
proggeramlug:fix/9104-named-class-self-binding
Aug 30, 2026
Merged

fix(hir): preserve class self brand through private updates#9126
proggeramlug merged 1 commit into
PerryTS:mainfrom
proggeramlug:fix/9104-named-class-self-binding

Conversation

@proggeramlug

@proggeramlug proggeramlug commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Preserve a named class expression's lexical brand owner through both guards emitted for a static private read-modify-write update.
  • Add HIR and end-to-end regressions for static-method inner-name resolution, nested-arrow self capture, and per-evaluation static private state.

Current upstream already resolves the issue's const C = class Named shape. This fixes the remaining nested-arrow/private-update failure and keeps both reported shapes gated.

Fixes #9104

Test plan

  • cargo fmt --all -- --check
  • cargo build --release -p perry -p perry-runtime-static -p perry-stdlib-static
  • cargo test --release -p perry-hir --lib (361 passed, 1 ignored)
  • PERRY_SKIP_BUILD=1 ./run_parity_tests.sh --filter 9104 (1/1 passed)
  • PERRY_SKIP_BUILD=1 ./run_parity_tests.sh --filter class_expr (19/19 passed)
  • python3 scripts/check_test_registration.py
  • ./scripts/pre-tag-check.sh --quick

Checklist

  • No workspace version bump or CLAUDE.md / CHANGELOG.md edit
  • Added the required changelog.d fragment

Summary by CodeRabbit

  • Bug Fixes

    • Fixed static private-field updates in nested arrow functions within named class expressions.
    • Preserved the correct class identity when reading and updating private static fields.
    • Ensured separate class evaluations retain independent private state.
  • Tests

    • Added coverage for named class expressions, static self-capture, nested arrows, and private-field updates.

@coderabbitai

coderabbitai Bot commented Aug 30, 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: 906ba86e-557d-46c1-918c-61575d5a7352

📥 Commits

Reviewing files that changed from the base of the PR and between da56c4a and 7d35eea.

📒 Files selected for processing (4)
  • changelog.d/9104-named-class-static-arrow.md
  • crates/perry-hir/src/lower/expr_member/private_guard.rs
  • crates/perry-hir/src/lower/tests.rs
  • test-files/test_gap_9104_named_class_expr_static_self_capture.ts

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


📝 Walkthrough

Walkthrough

The change preserves lexical class brand ownership through nested private-field guards. It adds lowering coverage for static private updates in arrows and runtime coverage for named class self-capture, nested arrows, and independent static private state.

Changes

Named class static self-binding

Layer / File(s) Summary
Preserve lexical brand ownership
crates/perry-hir/src/lower/expr_member/private_guard.rs
is_class_expr_self_binding now checks the inner receiver of PrivateGuard expressions.
Validate named class capture
crates/perry-hir/src/lower/tests.rs, test-files/test_gap_9104_named_class_expr_static_self_capture.ts, changelog.d/9104-named-class-static-arrow.md
Tests verify that private-field read and write guards retain the lexical brand owner. Runtime cases verify named class visibility, nested-arrow self-capture, and separate static private state. The changelog records the fix.

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

Merge Risk: ⚪ Minimal · up to 7d35e

This narrowly scoped compiler correctness fix preserves private-field behavior without changing public interfaces or weakening runtime checks; no actionable merge-blocking risk remains.

Suggested reviewers: thehypnoo

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 3 files. (1 skipped: 1… 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 and concisely identifies the main change: preserving the class self-brand through private updates in HIR.
Description check ✅ Passed The description provides a clear summary, identifies issue #9104, lists validation commands and results, and includes the relevant checklist items. The template headings for Changes and Related issue …
Linked Issues check ✅ Passed The changes address issue #9104. The HIR fix preserves the lexical brand owner through nested private guards, and the added HIR and end-to-end tests cover nested-arrow static private updates, inner-na…
Out of Scope Changes check ✅ Passed All changes are related to issue #9104: the HIR fix, regression tests, end-to-end coverage, and changelog fragment. No unrelated code or public API changes are reported.
Full details: Description check

Explanation

The description provides a clear summary, identifies issue #9104, lists validation commands and results, and includes the relevant checklist items. The template headings for Changes and Related issue are omitted, but their information is present in the summary and Fixes #9104 line.

Full details: Linked Issues check

Explanation

The changes address issue #9104. The HIR fix preserves the lexical brand owner through nested private guards, and the added HIR and end-to-end tests cover nested-arrow static private updates, inner-name resolution, per-evaluation state, and self-binding capture.

Full details: Docstring Coverage

Explanation

Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 3 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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
proggeramlug force-pushed the fix/9104-named-class-self-binding branch from 7d35eea to 9f294fb Compare August 30, 2026 07:27
@proggeramlug

Copy link
Copy Markdown
Contributor Author

Merged as part of a six-PR merge train: all six were cherry-picked onto one branch and validated together in a single build rather than six separate ones, at the maintainer's request to speed up a backlog. Combined validation: hir 361 passed, codegen 1352, runtime 2822 (exit 0, 0 abort markers), perry --bins 1066, and run_lint_gates.sh all 60 gates passed. git diff origin/main --diff-filter=D empty across the whole train.

Behaviour spot-check: my #9104 probe (23 class-self-binding shapes) is unchanged at 2/23 wrong, both of which are the pre-existing Named === C and nested-arrow-capture gaps — so this fixes its target without disturbing that surface.

@proggeramlug
proggeramlug merged commit 942fa7f into PerryTS:main Aug 30, 2026
17 of 20 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.

Named class expression: inner name unresolvable from a static method, and self-binding not captured into nested arrows

1 participant