Skip to content

Commit

Permalink
chore: add assertion to catch regressions
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAFrench committed Feb 7, 2024
1 parent faed734 commit b34dd32
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1514,7 +1514,7 @@ impl AcirContext {
}
Ok(())
}

// This is a hack to ensure that if we're compiling a brillig entrypoint function then
// we don't also add a number of range constraints.
if !unsafe_return_values {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ impl GeneratedAcir {
}
}

pub(crate) fn opcodes(&self) -> &[AcirOpcode] {
&self.opcodes
}

pub(crate) fn take_opcodes(&mut self) -> Vec<AcirOpcode> {
std::mem::take(&mut self.opcodes)
}
Expand Down
11 changes: 10 additions & 1 deletion compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,16 @@ impl Context {
for acir_var in output_vars {
self.acir_context.return_var(acir_var)?;
}
Ok(self.acir_context.finish(witness_inputs, Vec::new()))

let generated_acir = self.acir_context.finish(witness_inputs, Vec::new());

assert_eq!(
generated_acir.opcodes().len(),
1,
"Unconstrained programs should only generate a single opcode but multiple were emitted"
);

Ok(generated_acir)
}

/// Adds and binds `AcirVar`s for each numeric block parameter or block parameter array element.
Expand Down

0 comments on commit b34dd32

Please sign in to comment.