diff --git a/compiler/noirc_evaluator/src/ssa/opt/flatten_cfg.rs b/compiler/noirc_evaluator/src/ssa/opt/flatten_cfg.rs index d57c2cc7933..7700c7051ab 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/flatten_cfg.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/flatten_cfg.rs @@ -461,7 +461,7 @@ impl<'f> Context<'f> { let mut get_element = |array, typevars, len| { // The smaller slice is filled with placeholder data. Codegen for slice accesses must // include checks against the dynamic slice length so that this placeholder data is not incorrectly accessed. - if (len - 1) < index_value.to_u128() as usize { + if len <= index_value.to_u128() as usize { let zero = FieldElement::zero(); self.inserter.function.dfg.make_constant(zero, Type::field()) } else {