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(ssa refactor): Fix panic in acir-gen from multiplying values of different types #1769

Merged
merged 4 commits into from
Jun 22, 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
11 changes: 11 additions & 0 deletions crates/noirc_evaluator/src/ssa_refactor/opt/flatten_cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,17 @@ impl<'f> Context<'f> {
else_value: ValueId,
) -> ValueId {
let block = self.inserter.function.entry_block();
let then_type = self.inserter.function.dfg.type_of_value(then_value);
let else_type = self.inserter.function.dfg.type_of_value(else_value);
assert_eq!(
then_type, else_type,
"Expected values merged to be of the same type but found {then_type} and {else_type}"
);

// We must cast the bool conditions to the actual numeric type used by each value.
let then_condition = self.insert_instruction(Instruction::Cast(then_condition, then_type));
kevaundray marked this conversation as resolved.
Show resolved Hide resolved
let else_condition = self.insert_instruction(Instruction::Cast(else_condition, else_type));

let mul = Instruction::binary(BinaryOp::Mul, then_condition, then_value);
let then_value =
self.inserter.function.dfg.insert_instruction_and_results(mul, block, None).first();
Expand Down