Issue #4591 has been updated by Kenta Murata.


> ???????bug???????????????????追???????????????????????????
> ????????????????????????????????????????????????????????????
> max??????????????????????????込??????????????????????
> 
> ????????????議????????????????????????????????#4577??????????????

?????? issue ??? max ????義???????議?????????
以???????????????? bug ???対?????????????????解????????????

----------------------------------------
Bug #4591: (1.5...2).max #=> 1 (Range#max)
http://redmine.ruby-lang.org/issues/4591

Author: Masaya Tarui
Status: Assigned
Priority: Normal
Assignee: Kenta Murata
Category: core
Target version: 1.9.3
ruby -v: -


=begin

????(1.5...2).max???1????????????
begin???????????????????????????????????????????????????

?端????????Range?????????end???Integer?????????????end-1?????????????????????
?????????begin???Integer???????????????????????????????????????
?? begin???Integer??????????????????end???Integer????????????????
max????義?????????????????????????????????Error???????????親???????????????????

以??????????????????????????????????

Index: range.c
===================================================================
--- range.c     (????????? 31313)
+++ range.c     (?業??????)
@@ -670,6 +670,9 @@
                rb_raise(rb_eTypeError, "cannot exclude non Integer end value");

            }
            if (c == 0) return Qnil;
+           if (!FIXNUM_P(b) && !rb_obj_is_kind_of(b,rb_cInteger)) {
+               rb_raise(rb_eTypeError, "cannot exclude end value with non Integer begin value");
+           }
            if (FIXNUM_P(e)) {
                return LONG2NUM(FIX2LONG(e) - 1);
            }
Index: test/ruby/test_range.rb
===================================================================
--- test/ruby/test_range.rb     (????????? 31313)
+++ test/ruby/test_range.rb     (?業??????)
@@ -68,6 +68,8 @@
     assert_equal(2.0, (1.0..2.0).max)
     assert_equal(nil, (2.0..1.0).max)
     assert_raise(TypeError) { (1.0...2.0).max }
+    assert_raise(TypeError) { (1...1.5).max }
+    assert_raise(TypeError) { (1.5...2).max }

     assert_equal(-0x80000002, ((-0x80000002)...(-0x80000001)).max)

=end



-- 
http://redmine.ruby-lang.org