Skip to content

fix(hir): register computed methods on inline class construction - #10993

Closed
proggeramlug wants to merge 2 commits into
mainfrom
fix/10839-inline-class-iterator
Closed

proggeramlug wants to merge 2 commits into
mainfrom
fix/10839-inline-class-iterator

Conversation

@proggeramlug

@proggeramlug proggeramlug commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Direct new (class { ... })() lowering now runs the same computed-name registration prelude as ordinary class expressions before constructing the instance.
  • This makes an inline anonymous generator [Symbol.iterator]() visible to spread and other runtime iterator consumers.
  • Correct the existing regression test's comment to identify the separate direct-new lowering arm.

Fixes #10839.

Verification

  • On clean origin/main (c1569e244a), cargo test -p perry --test issue_5128_user_symbol_iterator class_expression_generator_symbol_iterator_is_iterable -- --exact --nocapture failed after the named class assertions, with TypeError: value is not iterable.
  • With this patch on the same checkout, that exact test passed (1 passed, 0 failed).
  • cargo fmt --all -- --check, scripts/check_file_size.sh, and git diff --check passed.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed inline anonymous classes so computed methods, including generator iterator methods, are registered before instances are constructed.
    • Ensured computed class members are evaluated in the correct order during construction.
  • Tests

    • Updated regression coverage for anonymous class expressions with computed iterator methods.
  • Documentation

    • Added a changelog entry describing the fix.

@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: 480f9b9f-831b-4c5a-93db-70a433934aaf

📥 Commits

Reviewing files that changed from the base of the PR and between c7cbc3c and d5363bb.

📒 Files selected for processing (3)
  • changelog.d/10993-inline-class-iterator.md
  • crates/perry-hir/src/lower/expr_new/non_ident.rs
  • crates/perry/tests/issue_5128_user_symbol_iterator.rs

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


📝 Walkthrough

Walkthrough

Inline anonymous class construction now prepares computed member names before instance creation. This registers methods such as [Symbol.iterator] for the inline lowering path. The changelog and regression-test comment describe the corrected behavior.

Changes

Inline class iterator fix

Layer / File(s) Summary
Computed-name lowering
crates/perry-hir/src/lower/expr_new/non_ident.rs
The inline class path prepares computed member names before construction. It sequences dynamic parent registration, computed-name evaluation, and instance construction.
Regression documentation
crates/perry/tests/issue_5128_user_symbol_iterator.rs, changelog.d/10993-inline-class-iterator.md
The regression-test comment identifies the direct anonymous class lowering path. The changelog records the computed-method registration fix.

Priority: ➖ Normal

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

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to d5363

Inline anonymous classes now register computed methods before construction, restoring iterator behavior for spread and related operations. No merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: registering computed methods during inline class construction.
Description check ✅ Passed The description provides a clear summary, explains the implementation and user-visible effect, identifies issue #10839, and records targeted test and validation results. It does not use the template's…
Linked Issues check ✅ Passed The change satisfies #10839. In crates/perry-hir/src/lower/expr_new/non_ident.rs, the direct anonymous-class new lowering now calls prepare_ordered_class_computed_names and places those evaluati…
Out of Scope Changes check ✅ Passed The changes stay within #10839. The implementation fixes direct inline class construction, the test comment identifies the affected lowering arm, and the changelog documents the fix. No unrelated beha…
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 3 functions across 2 files. (1 skipped: 1 …
✨ Finishing Touches 💡 1
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • 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 d5363bb96a. 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.

An inline anonymous class expression with a generator [Symbol.iterator]() is not iterable (and issue_5128's own test is red on main)

1 participant