Fix index out of bounds off-by-one error

This commit is contained in:
Sofia 2025-07-14 02:29:54 +03:00
parent c2a087785e
commit bad4713779

View File

@ -394,7 +394,7 @@ impl Expression {
let expr_t = expression.typecheck(state, hints, hint_t)?; let expr_t = expression.typecheck(state, hints, hint_t)?;
if let TypeKind::Array(inferred_ty, len) = expr_t { if let TypeKind::Array(inferred_ty, len) = expr_t {
if len < *idx { if len <= *idx {
return Err(ErrorKind::IndexOutOfBounds(*idx, len)); return Err(ErrorKind::IndexOutOfBounds(*idx, len));
} }
let ty = state.or_else( let ty = state.or_else(