diff --git a/compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs b/compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs index bfc4b1f3bde..772f2ab61ce 100644 --- a/compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs +++ b/compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs @@ -27,7 +27,6 @@ use crate::errors::{InternalError, InternalWarning, RuntimeError, SsaReport}; pub(crate) use acir_ir::generated_acir::GeneratedAcir; use acvm::acir::native_types::Witness; -use acvm::acir::BlackBoxFunc; use acvm::{ acir::{circuit::opcodes::BlockId, native_types::Expression}, FieldElement, @@ -405,7 +404,7 @@ impl Context { ) -> Result, RuntimeError> { let instruction = &dfg[instruction_id]; self.acir_context.set_call_stack(dfg.get_call_stack(instruction_id)); - let mut warnings = Vec::new(); + let warnings = Vec::new(); match instruction { Instruction::Binary(binary) => { let result_acir_var = self.convert_ssa_binary(binary, dfg)?; diff --git a/compiler/noirc_evaluator/src/ssa/ir/dfg.rs b/compiler/noirc_evaluator/src/ssa/ir/dfg.rs index f1e37a33224..7e55e9e324f 100644 --- a/compiler/noirc_evaluator/src/ssa/ir/dfg.rs +++ b/compiler/noirc_evaluator/src/ssa/ir/dfg.rs @@ -184,16 +184,6 @@ impl DataFlowGraph { let mut last_id = None; for instruction in instructions { - // Constrain instructions contain a reference to another instruction and thus need to be handled appropriately - // as to have a call stack associated with it. We want the assert message call to have the same call stack as the - // constrain for which we are resolving an assert message. - match &instruction { - Instruction::Constrain(_, _, assert_msg_instruction) => { - assert_msg_instruction - .map(|id| self.locations.insert(id, call_stack.clone())); - } - _ => {} - } let id = self.make_instruction(instruction, ctrl_typevars.clone()); self.blocks[block].insert_instruction(id); self.locations.insert(id, call_stack.clone()); diff --git a/compiler/noirc_evaluator/src/ssa/ir/instruction.rs b/compiler/noirc_evaluator/src/ssa/ir/instruction.rs index 62286bcfb2c..575cb8eb591 100644 --- a/compiler/noirc_evaluator/src/ssa/ir/instruction.rs +++ b/compiler/noirc_evaluator/src/ssa/ir/instruction.rs @@ -372,7 +372,7 @@ impl Instruction { | Instruction::Load { address: value } => { f(*value); } - Instruction::Constrain(lhs, rhs, assert_message) => { + Instruction::Constrain(lhs, rhs, _) => { f(*lhs); f(*rhs); } @@ -437,7 +437,7 @@ impl Instruction { } } Instruction::Constrain(lhs, rhs, msg) => { - let constraints = decompose_constrain(*lhs, *rhs, msg.clone(), dfg); + let constraints = decompose_constrain(*lhs, *rhs, *msg, dfg); if constraints.is_empty() { Remove } else { @@ -659,7 +659,7 @@ fn decompose_constrain( let one = dfg.make_constant(one, Type::bool()); [ - decompose_constrain(lhs, one, msg.clone(), dfg), + decompose_constrain(lhs, one, msg, dfg), decompose_constrain(rhs, one, msg, dfg), ] .concat() @@ -687,7 +687,7 @@ fn decompose_constrain( let zero = dfg.make_constant(zero, dfg.type_of_value(lhs)); [ - decompose_constrain(lhs, zero, msg.clone(), dfg), + decompose_constrain(lhs, zero, msg, dfg), decompose_constrain(rhs, zero, msg, dfg), ] .concat() diff --git a/compiler/noirc_evaluator/src/ssa/opt/bubble_up_constrains.rs b/compiler/noirc_evaluator/src/ssa/opt/bubble_up_constrains.rs index f40addc1a5b..350aa582cc0 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/bubble_up_constrains.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/bubble_up_constrains.rs @@ -22,15 +22,9 @@ impl Ssa { HashMap::with_capacity(instructions.len()); let dfg = &function.dfg; - let mut assert_message_instructions = Vec::new(); for instruction in instructions { let (lhs, rhs) = match dfg[instruction] { - Instruction::Constrain(lhs, rhs, assert_message_instr) => { - assert_message_instr.map(|instr| { - assert_message_instructions.push(instr); - }); - (lhs, rhs) - } + Instruction::Constrain(lhs, rhs, _) => (lhs, rhs), _ => { filtered_instructions.push(instruction); continue; diff --git a/compiler/noirc_evaluator/src/ssa/ssa_gen/context.rs b/compiler/noirc_evaluator/src/ssa/ssa_gen/context.rs index 183594b5a7d..ab8f4057aa9 100644 --- a/compiler/noirc_evaluator/src/ssa/ssa_gen/context.rs +++ b/compiler/noirc_evaluator/src/ssa/ssa_gen/context.rs @@ -478,7 +478,8 @@ impl<'a> FunctionContext<'a> { let rhs_as_unsigned = self.insert_safe_cast(rhs, Type::unsigned(bit_size), location); let lhs_sign = self.builder.insert_binary(lhs_as_unsigned, BinaryOp::Lt, half_width); let mut rhs_sign = self.builder.insert_binary(rhs_as_unsigned, BinaryOp::Lt, half_width); - let message = if is_sub { + // TODO: bring back assert_messages from codegen + let _message = if is_sub { // lhs - rhs = lhs + (-rhs) rhs_sign = self.builder.insert_not(rhs_sign); "attempt to subtract with overflow".to_string() diff --git a/compiler/noirc_evaluator/src/ssa/ssa_gen/mod.rs b/compiler/noirc_evaluator/src/ssa/ssa_gen/mod.rs index fef0dde270d..1258c1178d3 100644 --- a/compiler/noirc_evaluator/src/ssa/ssa_gen/mod.rs +++ b/compiler/noirc_evaluator/src/ssa/ssa_gen/mod.rs @@ -16,10 +16,7 @@ use crate::{ errors::RuntimeError, ssa::{ function_builder::data_bus::DataBusBuilder, - ir::{ - instruction::{Instruction, Intrinsic}, - types::NumericType, - }, + ir::{instruction::Intrinsic, types::NumericType}, }, }; diff --git a/noirc_macros/src/lib.rs b/noirc_macros/src/lib.rs index cda565d8323..7ff0798135f 100644 --- a/noirc_macros/src/lib.rs +++ b/noirc_macros/src/lib.rs @@ -1,11 +1,9 @@ // use noirc_frontend::macros_api::{parse_program, SortedModule, CrateId use noirc_frontend::macros_api::parse_program; +use noirc_frontend::macros_api::HirContext; use noirc_frontend::macros_api::SortedModule; use noirc_frontend::macros_api::{CrateId, FileId}; -use noirc_frontend::macros_api::{ - Expression, ExpressionKind, HirContext, Ident, Path, PathKind, Span, Statement, StatementKind, -}; use noirc_frontend::macros_api::{MacroError, MacroProcessor}; pub struct AssertMessageMacro; diff --git a/tooling/nargo/src/ops/execute.rs b/tooling/nargo/src/ops/execute.rs index aa50071531e..99c7ddb8e91 100644 --- a/tooling/nargo/src/ops/execute.rs +++ b/tooling/nargo/src/ops/execute.rs @@ -1,4 +1,3 @@ -use acvm::acir::circuit::OpcodeLocation; use acvm::pwg::{ACVMForeignCallResult, ACVMStatus, ErrorLocation, OpcodeResolutionError, ACVM}; use acvm::BlackBoxFunctionSolver; use acvm::{acir::circuit::Circuit, acir::native_types::WitnessMap}; @@ -49,11 +48,10 @@ pub fn execute_circuit( } ACVMStatus::RequiresForeignCall(foreign_call) => { let foreign_call_result = foreign_call_executor.execute(&foreign_call)?; - match &foreign_call_result { - ACVMForeignCallResult::ResolvedAssertMessage(assert_message) => { - current_assertion_message = Some(assert_message.to_owned()); - } - _ => {} + if let ACVMForeignCallResult::ResolvedAssertMessage(assert_message) = + &foreign_call_result + { + current_assertion_message = Some(assert_message.to_owned()); } acvm.resolve_pending_foreign_call(foreign_call_result); } @@ -63,29 +61,30 @@ pub fn execute_circuit( Ok(acvm.finalize()) } -fn resolve_call_stack(error: &OpcodeResolutionError) -> Option> { - match error { - OpcodeResolutionError::UnsatisfiedConstrain { - opcode_location: ErrorLocation::Resolved(opcode_location), - } => Some(vec![*opcode_location]), - OpcodeResolutionError::BrilligFunctionFailed { call_stack, .. } => Some(call_stack.clone()), - _ => None, - } -} +// TODO: bring these back for assert message made during compilation codegen +// fn resolve_call_stack(error: &OpcodeResolutionError) -> Option> { +// match error { +// OpcodeResolutionError::UnsatisfiedConstrain { +// opcode_location: ErrorLocation::Resolved(opcode_location), +// } => Some(vec![*opcode_location]), +// OpcodeResolutionError::BrilligFunctionFailed { call_stack, .. } => Some(call_stack.clone()), +// _ => None, +// } +// } -fn resolve_comptime_assert_message(error: &OpcodeResolutionError, circuit: &Circuit) -> NargoError { - let call_stack = resolve_call_stack(error); +// fn resolve_comptime_assert_message(error: &OpcodeResolutionError, circuit: &Circuit) -> NargoError { +// let call_stack = resolve_call_stack(error); - NargoError::ExecutionError(match call_stack { - Some(call_stack) => { - if let Some(assert_message) = circuit - .get_assert_message(*call_stack.last().expect("Call stacks should not be empty")) - { - ExecutionError::AssertionFailed(assert_message.to_owned(), call_stack) - } else { - ExecutionError::SolvingError(error.clone()) - } - } - None => ExecutionError::SolvingError(error.clone()), - }) -} +// NargoError::ExecutionError(match call_stack { +// Some(call_stack) => { +// if let Some(assert_message) = circuit +// .get_assert_message(*call_stack.last().expect("Call stacks should not be empty")) +// { +// ExecutionError::AssertionFailed(assert_message.to_owned(), call_stack) +// } else { +// ExecutionError::SolvingError(error.clone()) +// } +// } +// None => ExecutionError::SolvingError(error.clone()), +// }) +// }