From b5789554b52975cc18ce6e80e9033ec7394029c1 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 14 Jun 2019 07:09:53 -0700 Subject: carray-refset: bugfix: support negative indexing. * ffi.c (carray_refset): Support negative indexing by adding the length of the array to a negative index value. This is already done in carray_ref. --- ffi.c | 3 +++ 1 file changed, 3 insertions(+) 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); -- cgit v1.2.3