summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ffi.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/ffi.c b/ffi.c
index e2900d4d..2459dc17 100644
--- a/ffi.c
+++ b/ffi.c
@@ -4829,6 +4829,9 @@ val carray_refset(val carray, val idx, val newval)
struct carray *scry = carray_struct_checked(self, carray);
cnum ix = c_num(idx);
+ if (ix < 0)
+ ix += scry->nelem;
+
if (ix < 0 || (scry->nelem >= 0 && ix >= scry->nelem)) {
uw_throwf(error_s, lit("~a: ~s: index ~s out of bounds"),
self, carray, idx, nao);