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
11 changes: 10 additions & 1 deletion compiler/noirc_evaluator/src/ssa/ssa_gen/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -564,11 +564,20 @@ impl<'a> FunctionContext<'a> {
mut rhs: ValueId,
location: Location,
) -> Values {
let op = convert_operator(operator);
let mut op = convert_operator(operator);
if operator_requires_swapped_operands(operator) {
std::mem::swap(&mut lhs, &mut rhs);
}

if matches!(self.builder.type_of_value(lhs), Type::Numeric(NumericType::Signed { .. })) {
op = match op {
BinaryOp::Add { .. } => BinaryOp::Add { unchecked: true },
BinaryOp::Sub { .. } => BinaryOp::Sub { unchecked: true },
BinaryOp::Mul { .. } => BinaryOp::Mul { unchecked: true },
op => op,
};
}

let mut result = self.builder.set_location(location).insert_binary(lhs, op, rhs);

// Check for integer overflow
Expand Down
6 changes: 6 additions & 0 deletions test_programs/execution_success/regression_9047/Nargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[package]
name = "regression_9047"
type = "bin"
authors = [""]

[dependencies]
11 changes: 11 additions & 0 deletions test_programs/execution_success/regression_9047/src/main.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
fn main() -> pub str<2> {
let mut b = 0_i8;
if unsafe { func_1_proxy() } {
b = 112;
b = ((-b) * b);
};
"ok"
}
unconstrained fn func_1_proxy() -> bool {
false
}

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading