fix(hir_ty): diagnose unknown methods on inferred generics - #4534
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
⏭️ Performance benchmarks were skippedPerf benchmarks (CodSpeed) are opt-in on pull requests — they no longer run on every push. They always run automatically after merge to To run them on this PR, do any of the following, then push a commit (or re-run CI):
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe compiler now retries member resolution after inference variables become concrete. New tests validate E0007 diagnostics for missing methods and successful resolution for inferred generic receivers. ChangesInference-aware member resolution
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to The change is localized and no actionable merge-blocking risk remains beyond completing normal test checks. Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant InferenceTest
participant MemberCalleeResolver
participant DiagnosticReporter
InferenceTest->>MemberCalleeResolver: Resolve member on generic receiver
MemberCalleeResolver->>MemberCalleeResolver: Force variables and retry lookup
MemberCalleeResolver->>DiagnosticReporter: Report E0007 when member is missing
DiagnosticReporter-->>InferenceTest: Return diagnostic and source span
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Binary size checks passed✅ 7 passed
Generated by |
Summary
RepeatandArrayIteratorreceivers, and a valid inferred generic method control.Root cause
Probe.new(1)initially producesProbe<?T>while the argument constraint1 <: ?Tis pending. Call member resolution knew the class head but left the nested variable unresolved; after all lookup tiers missed, thehas_infercascade guard suppressed E0007. Finalization later grounded the receiver toProbe<int>, leaving MIR to encounter an impossible unknown field and emit the internal compiler error. The fix commits already-sufficient nested inference evidence at the call-resolution miss point and retries normal lookup, so the existing span-aware E0007 path owns the error before MIR.Relationship to #4468
This does not share the root cause of #4468. #4468 was fixed by #4490 and involved stale syntactic union/projection canonicalization plus a for-loop inference verdict/report mismatch. #4506 is an earlier member-call diagnostic deferral hole on a structured receiver containing nested inference variables, so this PR remains focused on that invariant.
Validation
cargo test -p baml_compiler2_hir_ty --libcargo test -p baml_tests --lib compiler2_tirmise run fmtmise run clippymise run clippy-wasmcargo insta test --test-runner nextest -p baml_tests -p baml_cli -p baml_lsp2_actions_tests --all-features --unreferenced=reject(2,969 passed; the sole shared-temp generator collision passed when rerun with an isolatedTMPDIR)Fixes #4506
Summary by CodeRabbit
Bug Fixes
Tests