commit 531866160abc54ad6ae0ebd94903f15b657d9a5b
parent b703b59d5daa4d6d29059a9deca64341231aaa42
Author: Eyal Sawady <ecs@d2evs.net>
Date: Fri, 13 Aug 2021 12:07:02 +0000
check: disallow unbounded slices
Signed-off-by: Eyal Sawady <ecs@d2evs.net>
Diffstat:
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/check.c b/src/check.c
@@ -2175,8 +2175,10 @@ check_expr_slice(struct context *ctx,
}
expr->slice.end = lower_implicit_cast(
&builtin_type_size, expr->slice.end);
- } else {
- // TODO: Assert that array type has a well-defined length
+ } else if (atype->storage == STORAGE_ARRAY
+ && atype->array.length == SIZE_UNDEFINED) {
+ return error(aexpr->loc, expr, errors,
+ "Must have end index on array of undefined length");
}
expr->result = type_store_lookup_slice(ctx->store, atype->array.members);