-
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
fix: substraction between relocatables should be signed #1218
Conversation
It is valid as per the reference implementation to substract two relocatables `a - b` where `b.offset > a.offset`. The fix consists in not using the trait as implemented for `Relocatable` (where it represents a positive distance between pointers) but to promote the offsets to `i128` and only substract them for `MaybeRelocatable`, as those are the language-level types.
23b1b99
to
2fc43d1
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.
LGTM. We can address TODOs and FIXMEs in following PRs.
Benchmark Results for unmodified programs 🚀
|
Codecov Report
@@ Coverage Diff @@
## main #1218 +/- ##
=======================================
Coverage 97.59% 97.59%
=======================================
Files 89 89
Lines 36159 36161 +2
=======================================
+ Hits 35289 35291 +2
Misses 870 870
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
…1218) * fix: substraction between relocatables should be signed It is valid as per the reference implementation to substract two relocatables `a - b` where `b.offset > a.offset`. The fix consists in not using the trait as implemented for `Relocatable` (where it represents a positive distance between pointers) but to promote the offsets to `i128` and only substract them for `MaybeRelocatable`, as those are the language-level types. * chore: remove uneeded stuff * Add fix holes to if_reloc_equal.cairo test * chore: changelog --------- Co-authored-by: Pedro Fontana <fontana.pedro93@gmail.com>
It is valid as per the reference implementation to substract two relocatables
a - b
whereb.offset > a.offset
. The current code returns an error due to negative result in that case.The fix consists in not using the trait as implemented for
Relocatable
(where it represents a positive distance between pointers) but to promote the offsets toi128
and only substract them forMaybeRelocatable
, as those are the language-level types.Checklist