Draft
Conversation
d3bec03 to
ae5a7a3
Compare
ae5a7a3 to
3f68050
Compare
There was a problem hiding this comment.
Pull request overview
This pull request implements checked arithmetic for integer operations in the Fe programming language. The changes make integer overflow and underflow cause runtime reverts by default, add compile-time detection for const expressions that would overflow, introduce explicit wrapping_* and saturating_* methods for non-reverting behavior, and add a #[test(should_revert)] attribute for testing revert conditions.
Changes:
- Default arithmetic operations now check for overflow/underflow and revert on detection
- Added
wrapping_*andsaturating_*trait methods for explicit overflow handling semantics - Augmented assignment operators now return the updated value instead of unit type
- Compile-time const evaluation validates arithmetic operations don't overflow
Reviewed changes
Copilot reviewed 60 out of 60 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| library/core/src/ops.fe | Added new traits for wrapping/saturating arithmetic; changed augmented assignment signatures to return Self |
| library/core/src/num.fe | Implemented checked arithmetic for all integer types with overflow detection; added wrapping/saturating variants |
| crates/hir/src/analysis/ty/const_ty.rs | Added compile-time checked arithmetic evaluation for const expressions |
| crates/hir/src/analysis/diagnostics.rs | Updated error message for invalid const expressions |
| crates/hir/src/core/hir_def/attr.rs | Added attribute helper methods for test annotations |
| crates/mir/src/lower/expr.rs | Updated MIR lowering to handle arithmetic as trait calls |
| crates/mir/src/lower/intrinsics.rs | Added panic detection for MIR terminating calls |
| crates/mir/src/lower/prepass.rs | Extended prepass to handle binary/unary expressions |
| crates/fe/src/test.rs | Added support for #[test(should_revert)] test attribute |
| Test files | Multiple new tests and snapshot updates for checked arithmetic behavior |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
wrapping_*andsaturating_*methods for cases where non-reverting behavior is desired#[test(should_revert)]test attribute to enable testing that code correctly reverts under expected conditions