File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -1133,6 +1133,11 @@ range_reverse_each(VALUE range)
1133
1133
VALUE end = RANGE_END (range );
1134
1134
int excl = EXCL (range );
1135
1135
1136
+ if (NIL_P (end )) {
1137
+ rb_raise (rb_eTypeError , "can't iterate from %s" ,
1138
+ rb_obj_classname (end ));
1139
+ }
1140
+
1136
1141
if (FIXNUM_P (beg ) && FIXNUM_P (end )) {
1137
1142
if (excl ) {
1138
1143
if (end == LONG2FIX (FIXNUM_MIN )) return range ;
Original file line number Diff line number Diff line change @@ -582,6 +582,14 @@ def test_reverse_each_for_beginless_range
582
582
assert_equal ( [ fmin -2 , fmin -3 ] , a )
583
583
end
584
584
585
+ def test_reverse_each_for_endless_range
586
+ assert_raise ( TypeError ) { ( 1 ..) . reverse_each { } }
587
+
588
+ enum = nil
589
+ assert_nothing_raised { enum = ( 1 ..) . reverse_each }
590
+ assert_raise ( TypeError ) { enum . each { } }
591
+ end
592
+
585
593
def test_reverse_each_for_single_point_range
586
594
fmin = RbConfig ::LIMITS [ 'FIXNUM_MIN' ]
587
595
fmax = RbConfig ::LIMITS [ 'FIXNUM_MAX' ]
You can’t perform that action at this time.
0 commit comments