diff --git a/compiler/noirc_evaluator/src/ssa/opt/flatten_cfg/value_merger.rs b/compiler/noirc_evaluator/src/ssa/opt/flatten_cfg/value_merger.rs index 6b923a2e42d..0a351148fa3 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/flatten_cfg/value_merger.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/flatten_cfg/value_merger.rs @@ -234,9 +234,9 @@ impl<'a> ValueMerger<'a> { /// such as with dynamic indexing of non-homogenous slices. fn make_slice_dummy_data(&mut self, typ: &Type) -> ValueId { match typ { - Type::Numeric(_) => { + Type::Numeric(numeric_type) => { let zero = FieldElement::zero(); - self.dfg.make_constant(zero, Type::field()) + self.dfg.make_constant(zero, Type::Numeric(*numeric_type)) } Type::Array(element_types, len) => { let mut array = im::Vector::new(); diff --git a/test_programs/execution_success/regression_sha256_slice/Nargo.toml b/test_programs/execution_success/regression_sha256_slice/Nargo.toml new file mode 100644 index 00000000000..759c3b20ba8 --- /dev/null +++ b/test_programs/execution_success/regression_sha256_slice/Nargo.toml @@ -0,0 +1,7 @@ +[package] +name = "regression_sha256_slice" +type = "bin" +authors = [""] +compiler_version = ">=0.26.0" + +[dependencies] \ No newline at end of file diff --git a/test_programs/execution_success/regression_sha256_slice/Prover.toml b/test_programs/execution_success/regression_sha256_slice/Prover.toml new file mode 100644 index 00000000000..8a027e9eca9 --- /dev/null +++ b/test_programs/execution_success/regression_sha256_slice/Prover.toml @@ -0,0 +1 @@ +x = ["5", "10"] diff --git a/test_programs/execution_success/regression_sha256_slice/src/main.nr b/test_programs/execution_success/regression_sha256_slice/src/main.nr new file mode 100644 index 00000000000..60b0911cf09 --- /dev/null +++ b/test_programs/execution_success/regression_sha256_slice/src/main.nr @@ -0,0 +1,12 @@ +use dep::std; + +fn main(x: [u8; 2]) { + let mut y = x.as_slice(); + let digest1 = std::hash::sha256_slice(y); + let mut v = y; + if x[0] != 0 { + v = y.push_back(x[0]); + } + let digest2 = std::hash::sha256_slice(v); + assert(digest1 != digest2); +}