-
Notifications
You must be signed in to change notification settings - Fork 160
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
Check for overflows in relocatable operations #859
Conversation
Codecov Report
@@ Coverage Diff @@
## math-error #859 +/- ##
===========================================
Coverage 96.90% 96.91%
===========================================
Files 69 69
Lines 29006 28965 -41
===========================================
- Hits 28108 28070 -38
+ Misses 898 895 -3
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
type Output = Result<Relocatable, MathError>; | ||
fn add(self, other: &MaybeRelocatable) -> Result<Relocatable, MathError> { |
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.
Typical (equivalent) signature:
type Output = Result<Relocatable, MathError>; | |
fn add(self, other: &MaybeRelocatable) -> Result<Relocatable, MathError> { | |
type Output = Result<Relocatable, MathError>; | |
fn add(self, other: &MaybeRelocatable) -> Self::Output { |
I'm not 100% sure returning a Result<_>
from an operator is what anybody would expect, as typically they'd use checked_*
to handle errors and let it panic!
otherwise. Still, this is infinitely better than what we had, so I'm OK with it.
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.
Much nicer
* Use only option for Memory.get * Fix some tests + refactor range_check validation * use proper error for get_memory_holes * Move MaybeRelocatable methods get_int_ref & get_reloctable to Option * Fix tests * Clippy * Fix `CairoRunner::write_output` so that it prints missing and relocatable values (#853) * Print relocatables & missing members in write_output * Add test * Move errors outputed by math_utils to MathError * Start moving relocatable operations to MathError * Fix tests * Remove math-related errors from vm error * Move conversion errors to MathError * Move type conversions to MathError * Remove unused errors * Clippy * Clippy * Simplify addition * Simplify addition * Clippy * Add math_errors.rs * Check for overflows in relocatable operations (#859) * Catch possible overflows in Relocatable::add * Move sub implementations to trait impl * Swap sub_usize for - operator * Vheck possible overflows in Add<i32> * Fix should_panic test * remove referenced add * Replace Relocatable methods for trait implementations * Catch overflows in mayberelocatable operations * Fix keccak * Clippy
This PR does the following:
Depends on #855