Skip to content

fix(transform): keep enum references out of cross-module inlining - #10866

Closed
proggeramlug wants to merge 1 commit into
PerryTS:mainfrom
proggeramlug:fix/10417-cross-module-enum-inline
Closed

proggeramlug wants to merge 1 commit into
PerryTS:mainfrom
proggeramlug:fix/10417-cross-module-enum-inline

Conversation

@proggeramlug

@proggeramlug proggeramlug commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Closes #10417.

Cross-module function and method bodies are copied into the importing module, but Expr::EnumMember is resolved against the current module's enum table. Reject enum-bearing bodies in all three harvesting paths so they remain outlined in the source module.

Regression coverage includes:

  • free-function graph harvesting
  • strict and extern-aware method harvesting
  • a two-module compile/run fixture covering the function and class-method forms

Tests:

  • cargo test -p perry-transform
  • cargo test -p perry --test source_graph_export_regressions issue_10417

Summary by CodeRabbit

  • Bug Fixes

    • Fixed cross-module optimization for functions and methods that reference TypeScript enum members.
    • Enum-dependent code now remains linked to its source module, preventing runtime lookup failures across module boundaries.
    • Resolved affected package compatibility issues, including scenarios such as Cheerio integration.
  • Tests

    • Added regression coverage for enum references in exported functions and class methods.

@coderabbitai

coderabbitai Bot commented Sep 21, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

Understand this PR’s impact

Explore downstream dependencies and potential security impact with Blast Radius.

View 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: 14d18a21-9862-44f0-beef-089cda1f79d7

📥 Commits

Reviewing files that changed from the base of the PR and between 47ade47 and 3235f95.

📒 Files selected for processing (5)
  • changelog.d/10417-cross-module-enum-inlining.md
  • crates/perry-transform/src/inline/cross_module.rs
  • crates/perry-transform/src/inline/mod.rs
  • crates/perry/tests/source_graph_export_regressions.rs
  • crates/perry/tests/source_graph_export_regressions/issue_10417.rs

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


📝 Walkthrough

Walkthrough

Cross-module inlining now rejects functions and methods that reference TypeScript enum members. Unit and integration tests verify that enum-dependent code remains in its source module and executes correctly across module boundaries.

Changes

Cross-module enum inlining safety

Layer / File(s) Summary
Reject enum-member inlining
crates/perry-transform/src/inline/cross_module.rs
The function and method safety checks now reject Expr::EnumMember expressions.
Validate source-module retention
crates/perry-transform/src/inline/mod.rs, crates/perry/tests/source_graph_export_regressions.rs, crates/perry/tests/source_graph_export_regressions/issue_10417.rs, changelog.d/10417-cross-module-enum-inlining.md
Unit tests reject enum-dependent cross-module candidates. An integration test verifies imported enum-dependent functions and class methods. The changelog records the fix.

Priority: ➖ Normal

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

Change: Bug fix · Severity of issue fixed: Medium

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 55.56% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 4 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 identifies the primary change: preventing cross-module inlining of functions and methods that reference enum members.
Description check ✅ Passed The description explains the problem, the implementation, the linked issue, and the test plan. It does not use the template headings or include the checklist, but it provides the required information …
Linked Issues check ✅ Passed Issue #10417 requires enum-bearing bodies to stay out of cross-module inlining for free functions, strict methods, and extern-aware methods. The PR adds Expr::EnumMember to all three safety checks i…
Out of Scope Changes check ✅ Passed The changed files support issue #10417. The transform change implements the safety checks. The unit test verifies the three harvesting paths. The integration test verifies cross-module runtime behavio…
Full details: Docstring Coverage

Explanation

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

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
🧪 Generate unit tests (beta)
  • 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 via merge train 252 (#10892) as v0.5.1632 — merge commit 841b605c97.

Carried with #10866, #10876, #10867, #10874 and #10862, which all touch overlapping surfaces.

Train-side work: #10867 and #10874 each add a module declaration to the same regression-test index (additive — both kept, sorted by issue); #10862's version-bump commits were excluded, since contributor PRs do not bump; and collect_modules.rs was allowlisted because it sat at exactly 2000 lines on main, so the one line these PRs add between them failed the cap.

Validation: 173 gap fixtures across seven areas, zero regressions, re-run against the current base after v0.5.1631 changed canonical_dir's path resolution — relevant because two of these PRs are about module resolution. All ratchets, cargo fmt, and cargo check --workspace --all-targets under -D warnings clean.

Closing here rather than merging — a train lands the commits directly.

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.

Cross-module inlining copies Enum.Member references into the importer: "enum member X.Y not found in enums table"

1 participant