Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
60e5f6e to
befbb33
Compare
…n-deterministic blocks
…stic blocks in analysis rules
- Renamed `AnalysisError` to `AnalysisDiagnostic` for clarity. - Updated the `Rule` trait and all implementing rules to use `AnalysisDiagnostic`. - Changed the return type of the `analyze` function to return `Result<AnalysisResult, AnalysisErrors>`. - Modified the `all_rules` function to return a static slice of rules instead of a vector of boxed rules. - Enhanced the walker context to track the kind of non-deterministic blocks. - Updated CLI output to display findings more succinctly. - Adjusted tests to reflect the new diagnostic structure and ensure correctness.
- Removed unnecessary line breaks and adjusted formatting in type checker tests for better readability. - Simplified function calls and expressions by consolidating match statements into single lines. - Enhanced clarity in assertions and checks throughout the type inference tests. - Streamlined utility functions by removing redundant code and improving consistency in function signatures. - Ensured consistent formatting across various test files to adhere to coding standards.
There was a problem hiding this comment.
Pull request overview
Introduces a new inference-analysis crate and wires an analyze phase into the compiler pipeline, while also migrating the AST and downstream crates/tests to a new typed-index, arena-backed representation.
Changes:
- Add
inference-analysiscrate with rule-based control-flow diagnostics and shared AST walker. - Refactor AST storage/API to
AstArena+ typed IDs (DefId,StmtId, etc.) and update type-checker/codegen accordingly. - Update tests and docs to align with the new AST and analysis pipeline.
Reviewed changes
Copilot reviewed 51 out of 64 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/src/type_checker/features.rs | Updates generic parsing tests to traverse the new arena/typed ID AST. |
| tests/src/lib.rs | Registers the new analysis test module. |
| tests/src/codegen/wasm/loops.rs | Adjusts cov_mark expected counts after codegen changes. |
| tests/src/codegen/wasm/algo_iter.rs | Adjusts cov_mark expected counts after codegen changes. |
| tests/src/codegen/wasm/algo_array.rs | Adjusts cov_mark expected counts after codegen changes. |
| tests/src/ast/primitive_type.rs | Migrates primitive type parsing tests to new typed arena representation. |
| tests/src/analysis/mod.rs | Adds analysis test module wiring. |
| tests/Cargo.toml | Adds dependency on inference-analysis for tests. |
| core/wasm-codegen/src/lib.rs | Updates typed-AST traversal to use arena + DefId and new helper APIs. |
| core/wasm-codegen/docs/arrays-and-memory.md | Updates documentation to reflect new variable name threading approach. |
| core/type-checker/src/typed_context.rs | Migrates TypedContext to new AstArena + typed NodeId; simplifies API surface. |
| core/type-checker/src/type_info.rs | Updates type conversion to work with arena-allocated TypeNode via TypeId. |
| core/type-checker/src/symbol_table.rs | Updates symbol registration to consume TypeInfo/arena IDs and refactors scope refs. |
| core/type-checker/src/lib.rs | Updates public docs and type-check entrypoint to accept AstArena. |
| core/type-checker/docs/api-guide.md | Removes outdated docs for APIs removed from TypedContext. |
| core/inference/src/lib.rs | Integrates new analysis phase and exposes analysis result/error types. |
| core/inference/Cargo.toml | Adds dependency on inference-analysis. |
| core/cli/src/main.rs | Updates CLI to run analysis and print findings/errors with new types. |
| core/ast/src/parser_context.rs | Migrates multi-file parsing skeleton to new AstArena. |
| core/ast/src/nodes_impl.rs | Replaces old node helper impls with AstArena query helpers for new representation. |
| core/ast/src/nodes.rs | Replaces macro-based node model with typed-ID-based node wrappers/enums. |
| core/ast/src/lib.rs | Updates crate docs/public modules to reflect AstArena design and adds typed IDs module. |
| core/ast/src/la_arena/mod.rs | Vendors rust-analyzer’s la-arena implementation for typed arena indices. |
| core/ast/src/la_arena/map.rs | Vendors rust-analyzer’s ArenaMap implementation. |
| core/ast/src/ids.rs | Introduces typed ID aliases and NodeId enum for heterogeneous references. |
| core/ast/src/extern_prelude.rs | Updates external module parsing to use AstArena. |
| core/ast/src/enums_impl.rs | Removes obsolete helper impls tied to the old AST model. |
| core/ast/src/arena.rs | Replaces old hash-map arena with typed AstArena and provides new query/source APIs. |
| core/ast/docs/location.md | Updates location/source retrieval docs for AstArena + NodeId. |
| core/ast/README.md | Updates README to reflect typed arena design and new usage patterns. |
| core/analysis/src/walker.rs | Adds shared statement walker with loop/non-det depth tracking + tests. |
| core/analysis/src/rules/return_inside_nondet_block.rs | Adds rule A005 preventing return inside non-det blocks. |
| core/analysis/src/rules/return_inside_loop.rs | Adds rule A003 preventing return inside loops. |
| core/analysis/src/rules/mod.rs | Registers all analysis rules. |
| core/analysis/src/rules/infinite_loop_without_break.rs | Adds rule A004 detecting infinite loops missing a reachable break. |
| core/analysis/src/rules/break_outside_loop.rs | Adds rule A001 preventing break outside loops. |
| core/analysis/src/rules/break_inside_nondet_block.rs | Adds rule A002 preventing break inside non-det blocks. |
| core/analysis/src/rule.rs | Introduces Rule trait and rule! macro for rule declarations. |
| core/analysis/src/lib.rs | Implements analyze() orchestration over registered rules. |
| core/analysis/src/errors.rs | Adds diagnostics, error/result aggregation, and display formatting. |
| core/analysis/README.md | Documents analysis crate architecture, rules, and output format. |
| core/analysis/Cargo.toml | Adds new inference-analysis crate metadata + dependencies. |
| Cargo.toml | Adds inference-analysis to workspace dependencies. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #37 #156