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: Dynamic assert messages in brillig #4531

Merged
merged 1 commit into from
Mar 12, 2024
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
22 changes: 11 additions & 11 deletions compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,17 +248,6 @@ impl<'block> BrilligBlock<'block> {
self.convert_ssa_binary(binary, dfg, result_var);
}
Instruction::Constrain(lhs, rhs, assert_message) => {
let condition = SingleAddrVariable {
address: self.brillig_context.allocate_register(),
bit_size: 1,
};

self.convert_ssa_binary(
&Binary { lhs: *lhs, rhs: *rhs, operator: BinaryOp::Eq },
dfg,
condition,
);

let assert_message = if let Some(error) = assert_message {
match error.as_ref() {
ConstrainError::Static(string) => Some(string.clone()),
Expand All @@ -282,6 +271,17 @@ impl<'block> BrilligBlock<'block> {
None
};

let condition = SingleAddrVariable {
address: self.brillig_context.allocate_register(),
bit_size: 1,
};

self.convert_ssa_binary(
&Binary { lhs: *lhs, rhs: *rhs, operator: BinaryOp::Eq },
dfg,
condition,
);

self.brillig_context.constrain_instruction(condition.address, assert_message);
self.brillig_context.deallocate_register(condition.address);
}
Expand Down
Loading