diff --git a/compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs b/compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs index 5819806b908..59c8fec083e 100644 --- a/compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs +++ b/compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs @@ -1038,7 +1038,7 @@ impl Context { } } - let element_type_sizes = if can_omit_element_sizes_array(&array_typ) { + let element_type_sizes = if !can_omit_element_sizes_array(&array_typ) { Some(self.init_element_type_sizes_array(&array_typ, array_id, None, dfg)?) } else { None @@ -1305,7 +1305,7 @@ impl Context { var_index: AcirVar, dfg: &DataFlowGraph, ) -> Result { - if can_omit_element_sizes_array(array_typ) { + if !can_omit_element_sizes_array(array_typ) { let element_type_sizes = self.init_element_type_sizes_array(array_typ, array_id, None, dfg)?; @@ -1792,7 +1792,7 @@ impl Context { let mut var_index = slice_length; self.array_set_value(element, result_block_id, &mut var_index)?; - let element_type_sizes = if can_omit_element_sizes_array(&array_typ) { + let element_type_sizes = if !can_omit_element_sizes_array(&array_typ) { Some(self.init_element_type_sizes_array( &array_typ, array_id, @@ -2061,5 +2061,12 @@ impl Context { // We can omit the element size array for arrays which have elements of size 1 and do not contain slices. // TODO: remove restriction on size 1 elements. fn can_omit_element_sizes_array(array_typ: &Type) -> bool { - array_typ.contains_slice_element() || array_typ.flattened_size() > 1 + if array_typ.contains_slice_element() { + return false; + } + let Type::Array(types, _) = array_typ else { + panic!("ICE: expected array type"); + }; + + types.len() == 1 && types[0].flattened_size() == 1 }