diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-02-18 14:38:05 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-02-18 14:38:05 -0500 |
| commit | f77a45095a76b99c9d470bc861bd69f5cb5b8742 (patch) | |
| tree | 609463ec5b7aab70955acacb7ee3bcc1deaec1d1 /builtins/array.h | |
| parent | 095970170ca3ef4a91970e02494f8056ca47c2c9 (diff) | |
Improved error messages
Diffstat (limited to 'builtins/array.h')
| -rw-r--r-- | builtins/array.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/builtins/array.h b/builtins/array.h index 8884f794..84edcb41 100644 --- a/builtins/array.h +++ b/builtins/array.h @@ -10,8 +10,8 @@ // Convert negative indices to back-indexed without branching: index0 = index + (index < 0)*(len+1)) - 1 #define $Array_get(type, x, i) ({ const array_t *$arr = x; int64_t $index = (int64_t)(i); \ int64_t $off = $index + ($index < 0) * ($arr->length + 1) - 1; \ - if (__builtin_expect($off < 0 && $off >= $arr->length, 0)) \ - fail("Invalid array index: %ld (array has length %ld)", $index, $arr->length); \ + if (__builtin_expect($off < 0 || $off >= $arr->length, 0)) \ + fail("Invalid array index: %ld (array has length %ld)\n", $index, $arr->length); \ *(type*)($arr->data + $arr->stride * $off);}) #define $Array_get_unchecked(type, x, i) ({ const array_t *$arr = x; int64_t $index = (int64_t)(i); \ int64_t $off = $index + ($index < 0) * ($arr->length + 1) - 1; \ |
