From bad4713779dd98bbd97d75ebd5e4f5a8050148f8 Mon Sep 17 00:00:00 2001 From: sofia Date: Mon, 14 Jul 2025 02:29:54 +0300 Subject: [PATCH] Fix index out of bounds off-by-one error --- reid/src/mir/typecheck.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reid/src/mir/typecheck.rs b/reid/src/mir/typecheck.rs index 1ed8cae..0f1d685 100644 --- a/reid/src/mir/typecheck.rs +++ b/reid/src/mir/typecheck.rs @@ -394,7 +394,7 @@ impl Expression { let expr_t = expression.typecheck(state, hints, hint_t)?; if let TypeKind::Array(inferred_ty, len) = expr_t { - if len < *idx { + if len <= *idx { return Err(ErrorKind::IndexOutOfBounds(*idx, len)); } let ty = state.or_else(