fix(inference): handle import cycles - #11008
Conversation
✅ Organic activityNo automation signals detected in the analyzed events. This is an automated analysis by AgentScan |
|
95c1239 to
e9a9f03
Compare
06bfe68 to
0e32611
Compare
✅ Organic activityNo automation signals detected in the analyzed events. This is an automated analysis by AgentScan |
WalkthroughImplemented cycle-aware module type inference using SCC analysis and Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
crates/biome_module_graph/src/db/type_inference/mod.rs (1)
158-177: 📐 Maintainability & Code Quality | 🔵 TrivialConsider a short doc comment.
inference_sccnext door has a solid rustdoc explaining the cycle-fallback contract, but this function (the actual Salsacycle_resultentry point) has none. A one-liner noting it's the fallback invoked when Salsa detects an import cycle, and that it delegates toinference_sccfor blocking, would help future readers who aren't already steeped in Salsa cycle-recovery semantics.📝 Suggested doc comment
+/// Salsa cycle-recovery fallback for `infer_module_types`, invoked when +/// inferring `module` would otherwise recurse into itself. Computes the +/// enclosing strongly connected component and re-resolves `module` with +/// cyclic imports blocked, leaving acyclic dependencies fully inferred. pub(super) fn infer_module_types_cycle_result<'db>( db: &'db dyn ModuleDb, _id: salsa::Id, module: ModuleInfo, ) -> Option<InferredModuleTypes<'db>> {As per coding guidelines: "Write comments only when they convey information not recoverable from code:
///documents contracts...//provides rationale."🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/biome_module_graph/src/db/type_inference/mod.rs` around lines 158 - 177, Add a concise Rustdoc comment above infer_module_types_cycle_result documenting that it is the Salsa cycle-result fallback invoked when an import cycle is detected and that it delegates blocking decisions to inference_scc. Do not alter the function’s behavior.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@crates/biome_module_graph/src/db/type_inference/mod.rs`:
- Around line 158-177: Add a concise Rustdoc comment above
infer_module_types_cycle_result documenting that it is the Salsa cycle-result
fallback invoked when an import cycle is detected and that it delegates blocking
decisions to inference_scc. Do not alter the function’s behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: a746e824-fbb2-46f7-b55b-11b883452938
📒 Files selected for processing (5)
crates/biome_module_graph/src/db/queries/type_inference.rscrates/biome_module_graph/src/db/type_inference/mod.rscrates/biome_module_graph/src/db/type_inference/resolver.rscrates/biome_module_graph/tests/spec_tests_v2.rscrates/biome_module_graph/tests/spec_tests_v2/cycles.test.rs

Summary
Adds cycle-safe Salsa inference for imported modules. Imports inside the active strongly connected component resolve conservatively while dependencies outside the cycle remain inferred.
Test Plan
Moved cycle coverage to a focused test file and passed all module-graph tests and all-target clippy.
Docs
N/A