summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--range.c7
-rw-r--r--test/ruby/test_array.rb3
2 files changed, 5 insertions, 5 deletions
diff --git a/range.c b/range.c
index 17d29925f1d..c019fcf2e0c 100644
--- a/range.c
+++ b/range.c
@@ -1332,7 +1332,7 @@ rb_range_values(VALUE range, VALUE *begp, VALUE *endp, int *exclp)
VALUE
rb_range_beg_len(VALUE range, long *begp, long *lenp, long len, int err)
{
- long beg, end, origbeg, origend;
+ long beg, end;
VALUE b, e;
int excl;
@@ -1341,8 +1341,6 @@ rb_range_beg_len(VALUE range, long *begp, long *lenp, long len, int err)
beg = NIL_P(b) ? 0 : NUM2LONG(b);
end = NIL_P(e) ? -1 : NUM2LONG(e);
if (NIL_P(e)) excl = 0;
- origbeg = beg;
- origend = end;
if (beg < 0) {
beg += len;
if (beg < 0)
@@ -1368,8 +1366,7 @@ rb_range_beg_len(VALUE range, long *begp, long *lenp, long len, int err)
out_of_range:
if (err) {
- rb_raise(rb_eRangeError, "%ld..%s%ld out of range",
- origbeg, excl ? "." : "", origend);
+ rb_raise(rb_eRangeError, "%+"PRIsVALUE" out of range", range);
}
return Qnil;
}
diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb
index 5d1785220ec..bc5d86354e7 100644
--- a/test/ruby/test_array.rb
+++ b/test/ruby/test_array.rb
@@ -2381,6 +2381,9 @@ class TestArray < Test::Unit::TestCase
assert_raise(ArgumentError) { [0].freeze[0, 0, 0] = 0 }
assert_raise(TypeError) { [0][:foo] = 0 }
assert_raise(FrozenError) { [0].freeze[:foo] = 0 }
+
+ # [Bug #17271]
+ assert_raise_with_message(RangeError, "-7.. out of range") { [*0..5][-7..] = 1 }
end
def test_first2