diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | numeric.c | 18 |
2 files changed, 21 insertions, 2 deletions
@@ -1,3 +1,8 @@ +Tue Sep 3 07:31:29 2013 Akinori MUSHA <[email protected]> + + * numeric.c (NUM_STEP_SCAN_ARGS): Numeral#step should raise + TypeError if a non-numeric parameter is given. + Tue Sep 3 07:28:49 2013 Tanaka Akira <[email protected]> * internal.h (bit_length): Add casts to fix complation error with @@ -1858,9 +1858,23 @@ ruby_num_interval_step_size(VALUE from, VALUE to, VALUE step, int excl) rb_raise(rb_eArgError, "step can't be 0"); \ } \ } \ - if (NIL_P(step)) step = INT2FIX(1); \ + if (NIL_P(step)) { \ + step = INT2FIX(1); \ + } \ + else { \ + if (!rb_obj_is_kind_of(step, rb_cNumeric)) { \ + rb_raise(rb_eTypeError, "step must be numeric"); \ + } \ + } \ desc = negative_int_p(step); \ - if (NIL_P(to)) to = desc ? DBL2NUM(-INFINITY) : DBL2NUM(INFINITY); \ + if (NIL_P(to)) { \ + to = desc ? DBL2NUM(-INFINITY) : DBL2NUM(INFINITY); \ + } \ + else { \ + if (!rb_obj_is_kind_of(to, rb_cNumeric)) { \ + rb_raise(rb_eTypeError, "limit must be numeric"); \ + } \ + } \ if (TYPE(to) == T_FLOAT) { \ double f = RFLOAT_VALUE(to); \ inf = isinf(f) && (signbit(f) ? desc : !desc); \ |