diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-05-12 17:23:46 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-05-12 17:23:46 +0000 |
commit | 34761b7f965ec7f2cab4179caa672b32a450dc79 (patch) | |
tree | 652b1e7dc1563291f5a0e8d2bf1759180769f596 /array.c | |
parent | e95cac18bd9648aa023e390a716c5887155b72b7 (diff) |
array.c: fix position in message
* array.c (rb_ary_insert): fix the position in error message, when
it is less than -1.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58694 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'array.c')
-rw-r--r-- | array.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -1786,7 +1786,12 @@ rb_ary_insert(int argc, VALUE *argv, VALUE ary) if (pos == -1) { pos = RARRAY_LEN(ary); } - if (pos < 0) { + else if (pos < 0) { + long minpos = -RARRAY_LEN(ary) - 1; + if (pos < minpos) { + rb_raise(rb_eIndexError, "index %ld too small for array; minimum: %ld", + pos, minpos); + } pos++; } rb_ary_splice(ary, pos, 0, argv + 1, argc - 1); |