Merge pull request #6906 from tf2spi/6902-off-by-one

Report range type correctly on out-of-bounds
This commit is contained in:
gingerBill
2026-06-29 13:51:09 +01:00
committed by GitHub

View File

@@ -5363,7 +5363,8 @@ gb_internal bool check_index_value(CheckerContext *c, Type *main_type, bool open
TEMPORARY_ALLOCATOR_GUARD();
String idx_str = big_int_to_string(temporary_allocator(), &i);
gbString expr_str = expr_to_string(operand.expr, temporary_allocator());
error(operand.expr, "Index '%s' is out of bounds range 0..<%lld, got %.*s", expr_str, max_count, LIT(idx_str));
char range_type = open_range ? '=' : '<';
error(operand.expr, "Index '%s' is out of bounds range 0..%c%lld, got %.*s", expr_str, range_type, max_count, LIT(idx_str));
return false;
}