From ff4ea60daf8a97d07a5b0419c05441d7312a1901 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 4 Aug 2024 14:22:58 -0400 Subject: Tweaks to array implementation, including changing how the bits are allocated, making more explicit checks for refcounts and max values, optimizations for certain methods, and adding compile-time errors for arrays that hold items that are too large. --- typecheck.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'typecheck.c') diff --git a/typecheck.c b/typecheck.c index 9e94ea2f..10c5820f 100644 --- a/typecheck.c +++ b/typecheck.c @@ -49,6 +49,9 @@ type_t *parse_type_ast(env_t *env, type_ast_t *ast) if (!item_t) code_err(item_type, "I can't figure out what this type is."); if (has_stack_memory(item_t)) code_err(item_type, "Arrays can't have stack references because the array may outlive the stack frame."); + if (padded_type_size(item_t) > ARRAY_MAX_STRIDE) + code_err(ast, "This array holds items that take up %ld bytes, but the maximum supported size is %ld bytes. Consider using an array of pointers instead.", + padded_type_size(item_t), ARRAY_MAX_STRIDE); return Type(ArrayType, .item_type=item_t); } case TableTypeAST: { -- cgit v1.2.3