mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Make Array#[]= raise IndexError.
If second param is negative, Array#[] raise IndexError.
This commit is contained in:
@@ -561,6 +561,10 @@ mrb_ary_splice(mrb_state *mrb, mrb_value ary, mrb_int head, mrb_int len, mrb_val
|
||||
mrb_int i, argc;
|
||||
|
||||
ary_modify(mrb, a);
|
||||
|
||||
/* len check */
|
||||
if (len < 0) mrb_raisef(mrb, E_INDEX_ERROR, "negative length (%S)", mrb_fixnum_value(len));
|
||||
|
||||
/* range check */
|
||||
if (head < 0) {
|
||||
head += a->len;
|
||||
|
||||
Reference in New Issue
Block a user