diff --git a/compiler/noirc_evaluator/src/errors.rs b/compiler/noirc_evaluator/src/errors.rs index 1e922060100..dd63a254a18 100644 --- a/compiler/noirc_evaluator/src/errors.rs +++ b/compiler/noirc_evaluator/src/errors.rs @@ -43,6 +43,8 @@ pub enum RuntimeError { UnconstrainedSliceReturnToConstrained { call_stack: CallStack }, #[error("All `oracle` methods should be wrapped in an unconstrained fn")] UnconstrainedOracleReturnToConstrained { call_stack: CallStack }, + #[error("Could not resolve some references to the array. All references must be resolved at compile time")] + UnknownReference { call_stack: CallStack }, } #[derive(Debug, Clone, Serialize, Deserialize)] @@ -123,7 +125,8 @@ impl RuntimeError { | RuntimeError::NestedSlice { call_stack, .. } | RuntimeError::BigIntModulus { call_stack, .. } | RuntimeError::UnconstrainedSliceReturnToConstrained { call_stack } - | RuntimeError::UnconstrainedOracleReturnToConstrained { call_stack } => call_stack, + | RuntimeError::UnconstrainedOracleReturnToConstrained { call_stack } + | RuntimeError::UnknownReference { call_stack } => call_stack, } } } diff --git a/compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs b/compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs index 2aac083d727..40170e58a30 100644 --- a/compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs +++ b/compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs @@ -682,7 +682,9 @@ impl<'a> Context<'a> { self.handle_array_operation(instruction_id, dfg)?; } Instruction::Allocate => { - unreachable!("Expected all allocate instructions to be removed before acir_gen") + return Err(RuntimeError::UnknownReference { + call_stack: self.acir_context.get_call_stack().clone(), + }); } Instruction::Store { .. } => { unreachable!("Expected all store instructions to be removed before acir_gen") @@ -1307,6 +1309,9 @@ impl<'a> Context<'a> { } Ok(AcirValue::Array(values)) } + Type::Reference(reference_type) => { + self.array_get_value(reference_type.as_ref(), block_id, var_index) + } _ => unreachable!("ICE: Expected an array or numeric but got {ssa_type:?}"), } }