Skip to content

Commit

Permalink
chore: add check that comparison is against zero
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAFrench committed Aug 8, 2023
1 parent 8206828 commit 067b621
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions crates/noirc_evaluator/src/ssa/ir/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -594,9 +594,11 @@ impl Binary {
return SimplifyResult::SimplifiedTo(zero);
}
if let Type::Numeric(NumericType::Unsigned { .. }) = operand_type {
// Unsigned values cannot be less than zero.
let zero = dfg.make_constant(FieldElement::zero(), Type::bool());
return SimplifyResult::SimplifiedTo(zero);
if rhs_is_zero {
// Unsigned values cannot be less than zero.
let zero = dfg.make_constant(FieldElement::zero(), Type::bool());
return SimplifyResult::SimplifiedTo(zero);
}
}
}
BinaryOp::And => {
Expand Down

0 comments on commit 067b621

Please sign in to comment.