-
Notifications
You must be signed in to change notification settings - Fork 28
User assert tracking #603
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
User assert tracking #603
Conversation
|
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 implements safety checks to ensure explicit user asserts and error conditions are preserved through optimization passes and not inadvertently eliminated or modified during compilation.
Key changes:
- Introduces explicit tracking of user-written assert/err operations via an
explicitflag - Adds validation at MIR and TEAL optimization stages to prevent removal of explicit checks
- Removes inline comment handling from TEAL operations in favor of a dedicated
teal_commentproperty
Reviewed Changes
Copilot reviewed 115 out of 2294 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/puya/ir/models.py | Added Assert operation class and explicit flag to Fail operation for tracking user-defined checks |
| src/puya/mir/models.py | Added Assert operation and explicit flag to Err for MIR-level explicit check tracking |
| src/puya/teal/models.py | Added Assert and updated Err with explicit flag; refactored comment handling to use teal_comment property |
| src/puya/mir/main.py | Added validation to ensure explicit checks are not removed during global stack allocation |
| src/puya/teal/main.py | Added validation to ensure explicit checks are preserved through TEAL optimization |
| src/puya/teal/optimize/peephole.py | Updated peephole optimizer to only optimize non-explicit asserts |
| src/puya/teal/optimize/constant_block.py | Simplified constant handling by removing TEAL alias resolution and comment logic |
| src/puya/teal/optimize/combine_pushes.py | Refactored to use comments field on combined push operations |
| src/puya/teal/builder.py | Updated to create Assert operations and handle constant comments during TEAL generation |
| test_cases/**/out_* | Updated test output files to reflect removal of inline comments (e.g., // 1) from constant operations |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
bad993b to
7e0b283
Compare
- use explicit `assert` op models from IR down in order to track explicit asserts vs generated asserts - similarly, track explicit vs generated `err` ops - require the use of `AssertExpression` node in AWST, both puyapy and puya-ts already do this - add explicit flag to `AssertExpression` for use by ARC-4 router code generator - with the explicit `assert` and `err` op models, simplify the handling of TEAL op comment/error formatting
…ons are preserved
7e0b283 to
bf6321b
Compare
Safety checks to ensure explicit user asserts and error conditions are preserved through optimization passes and not inadvertently eliminated or modified.