-
Notifications
You must be signed in to change notification settings - Fork 1
Register EnumDatatypeDef on-demand #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
22fb4df to
b4ddb31
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR refactors enum datatype definition registration from an upfront, crate-wide approach to an on-demand registration strategy. This enables support for externally-defined ADTs by registering enum definitions during basic block analysis when they are first encountered. The key architectural change involves sharing Rc<RefCell<EnumDefs>> between Env and Analyzer to allow dynamic updates during analysis, replacing the previous static copy approach.
- Introduces
EnumDefProvidertrait to abstract enum definition lookup - Replaces upfront enum registration in crate analysis with on-demand registration in basic block analysis
- Includes bug fixes in the CHC unboxing pass for proper handling of datatype sorts and matcher predicates
- Adds comprehensive test coverage for Result and Option enum types with both passing and failing cases
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/analyze.rs | Adds EnumDefs structure with on-demand get_or_register_enum_def method; refactors to share enum definitions via Rc<RefCell<EnumDefs>> |
| src/analyze/crate_.rs | Removes upfront register_enum_defs function that processed all enum definitions at crate initialization |
| src/analyze/basic_block.rs | Adds register_enum_defs to register enums found in local declarations before BB analysis; updates aggregate handling to use on-demand registration |
| src/refine/env.rs | Introduces EnumDefProvider trait and makes Env generic over it; updates to use trait for enum definition lookups |
| src/refine.rs | Exports new EnumDefProvider trait |
| src/chc/unbox.rs | Fixes bugs by adding unbox_datatype_sort call for DatatypeCtor and unbox_pred call for atom predicates |
| tests/ui/pass/result_struct.rs | Test case verifying Result enum handling with struct fields |
| tests/ui/pass/result_mut.rs | Test case for mutable Result enum operations |
| tests/ui/pass/option_mut.rs | Test case for mutable Option enum operations |
| tests/ui/pass/option_loop.rs | Test case for Option enum in loop contexts |
| tests/ui/pass/option_inc.rs | Test case for Option enum with increment operations |
| tests/ui/fail/result_struct.rs | Negative test case expecting failure with incorrect Result assertion |
| tests/ui/fail/result_mut.rs | Negative test case expecting failure with incorrect mutation assertion |
| tests/ui/fail/option_mut.rs | Negative test case expecting failure with incorrect Option mutation assertion |
| tests/ui/fail/option_loop.rs | Negative test case expecting failure with incorrect loop termination assertion |
| tests/ui/fail/option_inc.rs | Negative test case expecting failure with incorrect increment assertion |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
33b83d5 to
52b5563
Compare
Rc<RefCell<EnumDefs>>now.