From c1d99711655962c161fee2bca4ecd9fad5b5fb77 Mon Sep 17 00:00:00 2001 From: Maxim Vezenov Date: Fri, 21 Feb 2025 21:46:02 +0000 Subject: [PATCH 1/2] expand is_safe_index --- compiler/noirc_evaluator/src/ssa/ir/dfg.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/noirc_evaluator/src/ssa/ir/dfg.rs b/compiler/noirc_evaluator/src/ssa/ir/dfg.rs index aa517d43104..529aa6d24e0 100644 --- a/compiler/noirc_evaluator/src/ssa/ir/dfg.rs +++ b/compiler/noirc_evaluator/src/ssa/ir/dfg.rs @@ -658,7 +658,7 @@ impl DataFlowGraph { pub(crate) fn is_safe_index(&self, index: ValueId, array: ValueId) -> bool { #[allow(clippy::match_like_matches_macro)] match (self.type_of_value(array), self.get_numeric_constant(index)) { - (Type::Array(_, len), Some(index)) if index.to_u128() < (len as u128) => true, + (Type::Array(elements, len), Some(index)) if index.to_u128() < (len as u128 * elements.len() as u128) => true, _ => false, } } From c2fb7d46bc00157067b2dc8073bc44cbf0bea090 Mon Sep 17 00:00:00 2001 From: Maxim Vezenov Date: Fri, 21 Feb 2025 21:52:06 +0000 Subject: [PATCH 2/2] cargo fmt --- compiler/noirc_evaluator/src/ssa/ir/dfg.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/compiler/noirc_evaluator/src/ssa/ir/dfg.rs b/compiler/noirc_evaluator/src/ssa/ir/dfg.rs index 529aa6d24e0..adf0bc23b98 100644 --- a/compiler/noirc_evaluator/src/ssa/ir/dfg.rs +++ b/compiler/noirc_evaluator/src/ssa/ir/dfg.rs @@ -658,7 +658,11 @@ impl DataFlowGraph { pub(crate) fn is_safe_index(&self, index: ValueId, array: ValueId) -> bool { #[allow(clippy::match_like_matches_macro)] match (self.type_of_value(array), self.get_numeric_constant(index)) { - (Type::Array(elements, len), Some(index)) if index.to_u128() < (len as u128 * elements.len() as u128) => true, + (Type::Array(elements, len), Some(index)) + if index.to_u128() < (len as u128 * elements.len() as u128) => + { + true + } _ => false, } }