Skip to content
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion compiler/noirc_evaluator/src/acir/acir_context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ impl<F: AcirField, B: BlackBoxFunctionSolver<F>> AcirContext<F, B> {

// If `lhs` and `rhs` are known constants then we can calculate the result at compile time.
// `rhs` must be non-zero.
(Some(lhs_const), Some(rhs_const), _) if !rhs_const.is_zero() => {
(Some(lhs_const), Some(rhs_const), _) if rhs_const.to_u128() != 0 => {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked this and the case where there's a difference is for this field element: 340282366920938463463374607431768211456.
That's not zero, but to_u128 will return zero as it overflows the maximum u128.

Just noting this here, the fix is probably good.

let quotient = lhs_const.to_u128() / rhs_const.to_u128();
let remainder = lhs_const.to_u128() - quotient * rhs_const.to_u128();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[package]
name = "regression_8175"
type = "bin"
authors = [""]

[dependencies]
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
fn main() -> pub bool {
let d = ((false as Field) / (false as Field));
(d as u128) == 0
}
Loading