-
Notifications
You must be signed in to change notification settings - Fork 564
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
Added cast for signed integers. #3623
Added cast for signed integers. #3623
Conversation
6ff94d1
to
8f69581
Compare
881a43d
to
67af28e
Compare
8f69581
to
0fe46bc
Compare
67af28e
to
cbeda9e
Compare
0fe46bc
to
8a74bff
Compare
cbeda9e
to
bd9f5c7
Compare
918bbe4
to
59681b0
Compare
5601cda
to
e3e43e2
Compare
59681b0
to
324274e
Compare
324274e
to
8d98a4c
Compare
e3e43e2
to
35333c6
Compare
8d98a4c
to
2b696b0
Compare
35333c6
to
5326fe3
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.
Reviewable status: 2 of 7 files reviewed, 20 unresolved discussions (waiting on @orizi and @spapinistarkware)
crates/cairo-lang-sierra/src/extensions/modules/casts.rs
line 114 at r6 (raw file):
Previously, orizi wrote…
indeed - fixing.
Is it tested?
crates/cairo-lang-sierra/src/extensions/modules/casts.rs
line 121 at r7 (raw file):
if cast_type.overflow_above || cast_type.overflow_below { // Finding if the detected possible overflow is not actually possible, but a backwards // compatibilty based one. TODO(orizi): Remove this check after the
Move TODO to a separate line.
crates/cairo-lang-sierra/src/extensions/modules/casts.rs
line 121 at r7 (raw file):
if cast_type.overflow_above || cast_type.overflow_below { // Finding if the detected possible overflow is not actually possible, but a backwards // compatibilty based one. TODO(orizi): Remove this check after the
Suggestion:
// Finding if the detected possible overflow is not actually possible, but a backward
// compatibility based one. TODO(orizi): Remove this check after the
crates/cairo-lang-sierra/src/extensions/modules/casts.rs
line 123 at r7 (raw file):
// compatibilty based one. TODO(orizi): Remove this check after the // backwards compatibility is removed at next major sierra version. if from_info.signed || to_info.signed || from_info.nbits != to_info.nbits {
Another option is let same_type = from_info == to_info
and if (cast_type.overflow_above || cast_type.overflow_below) && !same_type {
Suggestion:
let backward_compatibility_exception = !from_info.signed && !to_info.signed && from_info.nbits == to_info.nbits;
if !backward_compatibility_exception {
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.
Reviewed 1 of 4 files at r7.
Reviewable status: 2 of 7 files reviewed, 19 unresolved discussions (waiting on @orizi and @spapinistarkware)
crates/cairo-lang-sierra/src/extensions/modules/casts.rs
line 121 at r7 (raw file):
Previously, liorgold2 wrote…
Move TODO to a separate line.
Never mind.
d9983bb
to
38995da
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.
Reviewable status: 2 of 7 files reviewed, 18 unresolved discussions (waiting on @liorgold2 and @spapinistarkware)
crates/cairo-lang-sierra/src/extensions/modules/casts.rs
line 114 at r6 (raw file):
Previously, liorgold2 wrote…
Is it tested?
it is - which confuses me on how this did not fail.
crates/cairo-lang-sierra/src/extensions/modules/casts.rs
line 121 at r7 (raw file):
if cast_type.overflow_above || cast_type.overflow_below { // Finding if the detected possible overflow is not actually possible, but a backwards // compatibilty based one. TODO(orizi): Remove this check after the
Done.
crates/cairo-lang-sierra/src/extensions/modules/casts.rs
line 123 at r7 (raw file):
Previously, liorgold2 wrote…
Another option is
let same_type = from_info == to_info
andif (cast_type.overflow_above || cast_type.overflow_below) && !same_type {
since the comment in needed anyway, and after the shortened version - i don't think the extra var is needed.
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.
Reviewable status: 2 of 7 files reviewed, 18 unresolved discussions (waiting on @liorgold2 and @spapinistarkware)
crates/cairo-lang-sierra/src/extensions/modules/casts.rs
line 114 at r6 (raw file):
Previously, orizi wrote…
it is - which confuses me on how this did not fail.
oh - got confused with downcast test - added one for upcast.
38995da
to
97e3500
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.
Reviewed 1 of 5 files at r8, 1 of 2 files at r9.
Reviewable status: 2 of 7 files reviewed, 12 unresolved discussions (waiting on @orizi and @spapinistarkware)
crates/cairo-lang-sierra/src/extensions/modules/casts.rs
line 114 at r6 (raw file):
Previously, orizi wrote…
oh - got confused with downcast test - added one for upcast.
Thanks
crates/cairo-lang-sierra/src/extensions/modules/casts.rs
line 48 at r7 (raw file):
Previously, orizi wrote…
indeed the fmt.
Move TODO to a separate line.
If needed add a blank line between. Seems weird that the formatter is intervening this way.
crates/cairo-lang-sierra/src/extensions/modules/casts.rs
line 121 at r9 (raw file):
if cast_type.overflow_above || cast_type.overflow_below { // Finding if the detected possible overflow is not actually possible, but a backward // compatibility based one (as smae type can have no overflow).
Suggestion:
// compatibility based one (as same type can have no overflow).
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.
Reviewed 2 of 5 files at r8, 1 of 2 files at r9, all commit messages.
Reviewable status: 5 of 7 files reviewed, 9 unresolved discussions (waiting on @orizi and @spapinistarkware)
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.
Reviewable status: 5 of 7 files reviewed, 9 unresolved discussions (waiting on @liorgold2 and @spapinistarkware)
crates/cairo-lang-sierra/src/extensions/modules/casts.rs
line 48 at r7 (raw file):
Previously, liorgold2 wrote…
Move TODO to a separate line.
If needed add a blank line between. Seems weird that the formatter is intervening this way.
Done.
crates/cairo-lang-sierra/src/extensions/modules/casts.rs
line 121 at r9 (raw file):
if cast_type.overflow_above || cast_type.overflow_below { // Finding if the detected possible overflow is not actually possible, but a backward // compatibility based one (as smae type can have no overflow).
Done.
97e3500
to
45ad990
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.
Reviewed 1 of 1 files at r10, all commit messages.
Reviewable status: 5 of 7 files reviewed, 8 unresolved discussions (waiting on @orizi and @spapinistarkware)
crates/cairo-lang-sierra-to-casm/src/invocations/casts.rs
line 56 at r10 (raw file):
} CastType { overflow_above: false, overflow_below: true } => { add_downcast_overflow_below(&mut casm_builder, value, range_check, &to_values.min)
Add an assert that from type is unsigned. Add an assumption to the documentation of add_downcast_overflow_below
.
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.
Reviewed 1 of 5 files at r8.
Reviewable status: 6 of 7 files reviewed, 8 unresolved discussions (waiting on @orizi and @spapinistarkware)
corelib/src/test/integer_test.cairo
line 940 at r10 (raw file):
} /// Checks if `a` is trivially castable to `B` and that `b` is castable to `A`, with the same value.
Fix documentation.
corelib/src/test/integer_test.cairo
line 967 at r10 (raw file):
OfAOnly, OfBOnly, }
Suggestion:
/// Describes the type of bound (min/max) in a cast.
///
/// For example, in a `u8 -> u16` cast, the lower bound is equal, and the upper bound
/// of `A` is inside `B`.
#[derive(Drop)]
enum BoundConfig {
/// The two bounds have the same value.
Equal,
/// The bound of A is inside the domain of B.
AInsideB,
/// The bound of B is inside the domain of A.
BInsideA,
}
corelib/src/test/integer_test.cairo
line 969 at r10 (raw file):
} /// Checks that casting from `A` to `B` are valid around the bounds.
or "as-intended"
Suggestion:
/// Checks that castings from `A` to `B` are correct around the bounds.
45ad990
to
18d46f1
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.
Reviewable status: 5 of 7 files reviewed, 8 unresolved discussions (waiting on @liorgold2 and @spapinistarkware)
corelib/src/test/integer_test.cairo
line 940 at r10 (raw file):
Previously, liorgold2 wrote…
Fix documentation.
Done.
corelib/src/test/integer_test.cairo
line 967 at r10 (raw file):
OfAOnly, OfBOnly, }
Done.
corelib/src/test/integer_test.cairo
line 969 at r10 (raw file):
Previously, liorgold2 wrote…
or "as-intended"
Done.
crates/cairo-lang-sierra-to-casm/src/invocations/casts.rs
line 56 at r10 (raw file):
Previously, liorgold2 wrote…
Add an assert that from type is unsigned. Add an assumption to the documentation of
add_downcast_overflow_below
.
Done.
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.
Reviewed 1 of 2 files at r11, all commit messages.
Reviewable status: 6 of 7 files reviewed, 7 unresolved discussions (waiting on @spapinistarkware)
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.
Reviewed 1 of 2 files at r11.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @orizi and @spapinistarkware)
corelib/src/test/integer_test.cairo
line 1013 at r11 (raw file):
/// Checks that castings from `SubType` to `SuperType` are correct around the bounds, where /// `SubType` is strictly contained in `SuperType`.
Suggestion:
/// `SubType` is strictly contained (in both bounds) in `SuperType`.
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.
Dismissed @spapinistarkware from a discussion.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @orizi)
6ed4910
to
86c192f
Compare
86c192f
to
39b81d4
Compare
commit-id:c56d4b74
39b81d4
to
bcfa44c
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.
Reviewed 3 of 3 files at r12, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @orizi)
Stack:
This change is