From 342619300ce26f9a134249002270c5d38d5993b3 Mon Sep 17 00:00:00 2001 From: mame Date: Fri, 22 Jun 2018 02:58:39 +0000 Subject: range.c: Range#size now returns Float::INFINITY if it is endless Fixes [Bug #14699] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63715 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- range.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'range.c') diff --git a/range.c b/range.c index 3414525a12..c2fa6abeeb 100644 --- a/range.c +++ b/range.c @@ -749,9 +749,15 @@ static VALUE range_size(VALUE range) { VALUE b = RANGE_BEG(range), e = RANGE_END(range); - if (rb_obj_is_kind_of(b, rb_cNumeric) && rb_obj_is_kind_of(e, rb_cNumeric)) { - return ruby_num_interval_step_size(b, e, INT2FIX(1), EXCL(range)); + if (rb_obj_is_kind_of(b, rb_cNumeric)) { + if (rb_obj_is_kind_of(e, rb_cNumeric)) { + return ruby_num_interval_step_size(b, e, INT2FIX(1), EXCL(range)); + } + if (NIL_P(e)) { + return DBL2NUM(HUGE_VAL); + } } + return Qnil; } -- cgit v1.2.3