aboutsummaryrefslogtreecommitdiffstats
path: root/numeric.c
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-09-02 22:54:58 +0000
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-09-02 22:54:58 +0000
commitc68596aef1c03678b196c3ee1269df09710dbdbf (patch)
tree190b43f177a49138a27f8ffb0e31936161a41570 /numeric.c
parent0c3d1245715dd7708a594299228ad6f62e38aa74 (diff)
downloadruby-c68596aef1c03678b196c3ee1269df09710dbdbf.tar.gz
Retain behavior of Numeric#step when nil is given as second argument.
* numeric.c (NUM_STEP_SCAN_ARGS): On sencond thought, keep Numeral#step backward compatible in that it raises TypeError when nil is given as second argument. * test/ruby/test_float.rb (TestFloat#test_num2dbl): Revert. * test/ruby/test_numeric.rb (TestNumeric#test_step): Fix test cases for the above change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42788 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/numeric.c b/numeric.c
index 57b61759c1..780186eb58 100644
--- a/numeric.c
+++ b/numeric.c
@@ -1854,6 +1854,9 @@ ruby_num_interval_step_size(VALUE from, VALUE to, VALUE step, int excl)
} \
else { \
/* compatibility */ \
+ if (argc > 1 && NIL_P(step)) { \
+ rb_raise(rb_eTypeError, "step must be numeric"); \
+ } \
if (rb_equal(step, INT2FIX(0))) { \
rb_raise(rb_eArgError, "step can't be 0"); \
} \