diff --git a/compiler/noirc_evaluator/src/ssa/opt/die.rs b/compiler/noirc_evaluator/src/ssa/opt/die.rs index b9804062118..095413d7b9a 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/die.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/die.rs @@ -377,13 +377,12 @@ fn handle_array_get_group( next_out_of_bounds_index: &mut Option, possible_index_out_of_bounds_indexes: &mut Vec, ) { - let Some(array_length) = function.dfg.try_get_array_length(*array) else { + if function.dfg.try_get_array_length(*array).is_none() { // Nothing to do for slices return; }; - let flattened_size = function.dfg.type_of_value(*array).flattened_size(); - let element_size = flattened_size / array_length; + let element_size = function.dfg.type_of_value(*array).element_size(); if element_size <= 1 { // Not a composite type return; diff --git a/test_programs/execution_failure/empty_composite_array_get/Nargo.toml b/test_programs/execution_failure/empty_composite_array_get/Nargo.toml new file mode 100644 index 00000000000..fa4614c8351 --- /dev/null +++ b/test_programs/execution_failure/empty_composite_array_get/Nargo.toml @@ -0,0 +1,7 @@ +[package] +name = "empty_composite_array_get" +type = "bin" +authors = [""] +compiler_version = ">=0.32.0" + +[dependencies] \ No newline at end of file diff --git a/test_programs/execution_failure/empty_composite_array_get/Prover.toml b/test_programs/execution_failure/empty_composite_array_get/Prover.toml new file mode 100644 index 00000000000..ff52a8c5bce --- /dev/null +++ b/test_programs/execution_failure/empty_composite_array_get/Prover.toml @@ -0,0 +1 @@ +empty_input = [] \ No newline at end of file diff --git a/test_programs/execution_failure/empty_composite_array_get/src/main.nr b/test_programs/execution_failure/empty_composite_array_get/src/main.nr new file mode 100644 index 00000000000..1ed9fe4a5e0 --- /dev/null +++ b/test_programs/execution_failure/empty_composite_array_get/src/main.nr @@ -0,0 +1,5 @@ +fn main(empty_input: [(Field, Field); 0]) { + let empty_array: [(Field, Field); 0] = []; + let _ = empty_input[0]; + let _ = empty_array[0]; +}