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: error for allocate instructions in acir-gen #5200

Merged
merged 2 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion compiler/noirc_evaluator/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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,
}
}
}
Expand Down
7 changes: 6 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,7 @@
#[tracing::instrument(level = "trace", skip_all)]
pub(crate) fn into_acir(self, brillig: &Brillig) -> Result<Artifacts, RuntimeError> {
let mut acirs = Vec::new();
// TODO: can we parallelise this?

Check warning on line 284 in compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (parallelise)
let mut shared_context = SharedContext::default();
for function in self.functions.values() {
let context = Context::new(&mut shared_context);
Expand Down Expand Up @@ -682,7 +682,9 @@
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")
Expand Down Expand Up @@ -1307,6 +1309,9 @@
}
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:?}"),
}
}
Expand Down
Loading