Skip to content

Commit

Permalink
fix: Enforce matching types of binary ops in SSA (#4391)
Browse files Browse the repository at this point in the history
# Description

## Problem\*

Resolves #4275

## Summary\*

Adds a check in insert_binary to make sure we don't start codegening
non-matching binary ops again.


## Additional Context



## Documentation\*

Check one:
- [x] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[Exceptional Case]** Documentation to be submitted in a separate
PR.

# PR Checklist\*

- [x] I have tested the changes locally.
- [x] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
  • Loading branch information
sirasistant authored Feb 16, 2024
1 parent f77f702 commit 70866ae
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions compiler/noirc_evaluator/src/ssa/function_builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,11 @@ impl FunctionBuilder {
operator: BinaryOp,
rhs: ValueId,
) -> ValueId {
assert_eq!(
self.type_of_value(lhs),
self.type_of_value(rhs),
"ICE - Binary instruction operands must have the same type"
);
let instruction = Instruction::Binary(Binary { lhs, rhs, operator });
self.insert_instruction(instruction, None).first()
}
Expand Down

0 comments on commit 70866ae

Please sign in to comment.