summaryrefslogtreecommitdiff
path: root/range.c
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-06-22 02:58:39 (GMT)
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-06-22 02:58:39 (GMT)
commit342619300ce26f9a134249002270c5d38d5993b3 (patch)
treee5596f52d92004847655de82aac3c5512a4462a9 /range.c
parentc19ecf05b4c728951e1a1e223a40ae6883a4f8e0 (diff)
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
Diffstat (limited to 'range.c')
-rw-r--r--range.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/range.c b/range.c
index 3414525..c2fa6ab 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;
}