diff --git a/range.c b/range.c index 71d81fa6c4..67ead72e78 100644 --- a/range.c +++ b/range.c @@ -408,7 +408,7 @@ range_step(int argc, VALUE *argv, VALUE range) } while (FIXABLE(i)); b = LONG2NUM(i); - for (;; b = rb_funcallv(b, id_succ, 0, 0)) + for (;; b = rb_big_plus(b, step)) rb_yield(b); } else if (FIXNUM_P(b) && FIXNUM_P(e) && FIXNUM_P(step)) { /* fixnums are special */ diff --git a/test/ruby/test_range.rb b/test/ruby/test_range.rb index dbfe495f29..beb0b956cd 100644 --- a/test/ruby/test_range.rb +++ b/test/ruby/test_range.rb @@ -245,10 +245,13 @@ class TestRange < Test::Unit::TestCase (2**32-1 .. ).step(2) {|x| a << x; break if a.size == 2 } assert_equal([4294967295, 4294967297], a) - a = [] max = RbConfig::LIMITS["FIXNUM_MAX"] + a = [] (max..).step {|x| a << x; break if a.size == 2 } assert_equal([max, max+1], a) + a = [] + (max..).step(max) {|x| a << x; break if a.size == 4 } + assert_equal([max, 2*max, 3*max, 4*max], a) o1 = Object.new o2 = Object.new