diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-08-04 14:22:58 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-08-04 14:22:58 -0400 |
| commit | ff4ea60daf8a97d07a5b0419c05441d7312a1901 (patch) | |
| tree | 3bb7f991ae7bbe4ad3a703c5df09c0d5625b19ca /compile.c | |
| parent | adccc5688062271ca6999a15d6c09bd106462704 (diff) | |
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.
Diffstat (limited to 'compile.c')
| -rw-r--r-- | compile.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -1633,12 +1633,15 @@ CORD compile(env_t *env, ast_t *ast) "})"); } case Array: { + type_t *array_type = get_type(env, ast); + if (padded_type_size(Match(array_type, ArrayType)->item_type) > 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(Match(array_type, ArrayType)->item_type), ARRAY_MAX_STRIDE); + auto array = Match(ast, Array); if (!array->items) return "(array_t){.length=0}"; - type_t *array_type = get_type(env, ast); - int64_t n = 0; for (ast_list_t *item = array->items; item; item = item->next) { ++n; |
