Skip to content
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(3275): activate brillig modulo test with negative integers #3318

Merged
merged 1 commit into from
Oct 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,16 @@ fn main() {
assert(signed_modulo(5, 3) == 2);
assert(signed_modulo(2, 3) == 2);

// See #3275.
// Commented out for now since the previous values which would overflow an i4 are now a compiler error.
// let minus_two: i4 = -2; // 14
// let minus_three: i4 = -3; // 13
// let minus_five: i4 = -5; // 11
let minus_two: i4 = -2; // 14
let minus_three: i4 = -3; // 13
let minus_five: i4 = -5; // 11

// // (5 / -3) * -3 + 2 = -1 * -3 + 2 = 3 + 2 = 5
// assert(signed_modulo(5, minus_three) == 2);
// // (-5 / 3) * 3 - 2 = -1 * 3 - 2 = -3 - 2 = -5
// assert(signed_modulo(minus_five, 3) == minus_two);
// // (-5 / -3) * -3 - 2 = 1 * -3 - 2 = -3 - 2 = -5
// assert(signed_modulo(minus_five, minus_three) == minus_two);
// (5 / -3) * -3 + 2 = -1 * -3 + 2 = 3 + 2 = 5
assert(signed_modulo(5, minus_three) == 2);
// (-5 / 3) * 3 - 2 = -1 * 3 - 2 = -3 - 2 = -5
assert(signed_modulo(minus_five, 3) == minus_two);
// (-5 / -3) * -3 - 2 = 1 * -3 - 2 = -3 - 2 = -5
assert(signed_modulo(minus_five, minus_three) == minus_two);
}

unconstrained fn modulo(x: u32, y: u32) -> u32 {
Expand Down