Skip to content

Commit ba6c734

Browse files
committed
numeric.c: no extra checks
* numeric.c (NUM_STEP_SCAN_ARGS): remove extra class checks, which cause the incompatibilities. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42876 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 622a2af commit ba6c734

File tree

3 files changed

+3
-13
lines changed

3 files changed

+3
-13
lines changed

numeric.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1864,20 +1864,10 @@ ruby_num_interval_step_size(VALUE from, VALUE to, VALUE step, int excl)
18641864
if (NIL_P(step)) { \
18651865
step = INT2FIX(1); \
18661866
} \
1867-
else { \
1868-
if (!rb_obj_is_kind_of(step, rb_cNumeric)) { \
1869-
rb_raise(rb_eTypeError, "step must be numeric"); \
1870-
} \
1871-
} \
18721867
desc = negative_int_p(step); \
18731868
if (NIL_P(to)) { \
18741869
to = desc ? DBL2NUM(-INFINITY) : DBL2NUM(INFINITY); \
18751870
} \
1876-
else { \
1877-
if (!rb_obj_is_kind_of(to, rb_cNumeric)) { \
1878-
rb_raise(rb_eTypeError, "limit must be numeric"); \
1879-
} \
1880-
} \
18811871
} while (0)
18821872

18831873
#define NUM_STEP_GET_INF(to, desc, inf) do { \

test/ruby/test_float.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ def test_invalid_str
558558
end
559559

560560
def test_num2dbl
561-
assert_raise(TypeError) do
561+
assert_raise(ArgumentError) do
562562
1.0.step(2.0, "0.5") {}
563563
end
564564
assert_raise(TypeError) do

test/ruby/test_numeric.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,8 @@ def test_step
227227
assert_raise(ArgumentError) { 1.step(10, 1, 0).size }
228228
assert_raise(ArgumentError) { 1.step(10, 0) { } }
229229
assert_raise(ArgumentError) { 1.step(10, 0).size }
230-
assert_raise(TypeError) { 1.step(10, "1") { } }
231-
assert_raise(TypeError) { 1.step(10, "1").size }
230+
assert_raise(ArgumentError) { 1.step(10, "1") { } }
231+
assert_raise(ArgumentError) { 1.step(10, "1").size }
232232
assert_raise(TypeError) { 1.step(10, nil) { } }
233233
assert_raise(TypeError) { 1.step(10, nil).size }
234234
assert_nothing_raised { 1.step(by: 0, to: nil) }

0 commit comments

Comments
 (0)