diff --git a/compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs b/compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs index 93e5722aee0..bbd53a5a204 100644 --- a/compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs +++ b/compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs @@ -1248,7 +1248,7 @@ impl Context { terminator: &TerminatorInstruction, dfg: &DataFlowGraph, ) -> Result<(), InternalError> { - let (return_values, call_stack) = match terminator { + let (return_values, _call_stack) = match terminator { TerminatorInstruction::Return { return_values, call_stack } => { (return_values, call_stack) } @@ -1259,9 +1259,12 @@ impl Context { // will expand the array if there is one. let return_acir_vars = self.flatten_value_list(return_values, dfg); for acir_var in return_acir_vars { - if self.acir_context.is_constant(&acir_var) { - return Err(InternalError::ReturnConstant { call_stack: call_stack.clone() }); - } + // TODO(Guillaume) -- disabled as it has shown to break + // TODO with important programs. We will add it back once + // TODO we change it to a warning. + // if self.acir_context.is_constant(&acir_var) { + // return Err(InternalError::ReturnConstant { call_stack: call_stack.clone() }); + // } self.acir_context.return_var(acir_var)?; } Ok(()) @@ -1859,48 +1862,3 @@ impl Context { } } } - -#[cfg(test)] -mod tests { - use std::{collections::HashMap, rc::Rc}; - - use acvm::FieldElement; - - use crate::{ - brillig::Brillig, - errors::{InternalError, RuntimeError}, - ssa::{ - function_builder::FunctionBuilder, - ir::{function::RuntimeType, map::Id, types::Type}, - }, - }; - - use super::Context; - - #[test] - fn returns_body_scoped_arrays() { - // fn main { - // b0(): - // return [Field 1] - // } - let func_id = Id::test_new(0); - let mut builder = FunctionBuilder::new("func".into(), func_id, RuntimeType::Acir); - - let one = builder.field_constant(FieldElement::one()); - - let element_type = Rc::new(vec![Type::field()]); - let array_type = Type::Array(element_type, 1); - let array = builder.array_constant(im::Vector::unit(one), array_type); - - builder.terminate_with_return(vec![array]); - - let ssa = builder.finish(); - - let context = Context::new(); - let acir = context - .convert_ssa(ssa, Brillig::default(), &HashMap::default()) - .expect_err("Return constant value"); - assert!(matches!(acir, RuntimeError::InternalError(InternalError::ReturnConstant { .. }))); - } -} -// diff --git a/tooling/nargo_cli/tests/compile_failure/constant_return/Nargo.toml b/tooling/nargo_cli/tests/compile_failure/constant_return/Nargo.toml deleted file mode 100644 index d74eea4d3a7..00000000000 --- a/tooling/nargo_cli/tests/compile_failure/constant_return/Nargo.toml +++ /dev/null @@ -1,7 +0,0 @@ -[package] -name = "constant_return" -type = "bin" -authors = [""] -compiler_version = "0.1" - -[dependencies] diff --git a/tooling/nargo_cli/tests/compile_failure/constant_return/Prover.toml b/tooling/nargo_cli/tests/compile_failure/constant_return/Prover.toml deleted file mode 100644 index fe9e83b06aa..00000000000 --- a/tooling/nargo_cli/tests/compile_failure/constant_return/Prover.toml +++ /dev/null @@ -1 +0,0 @@ -_x = "3" diff --git a/tooling/nargo_cli/tests/compile_failure/constant_return/src/main.nr b/tooling/nargo_cli/tests/compile_failure/constant_return/src/main.nr deleted file mode 100644 index 4972d514860..00000000000 --- a/tooling/nargo_cli/tests/compile_failure/constant_return/src/main.nr +++ /dev/null @@ -1,7 +0,0 @@ -// This is a test for simple return with a constant. -// -// Note: There's a possibility in the future that -// a test before ACIR gen optimizes this test. -fn main(_x : Field) -> pub Field { - 5 -}