summaryrefslogtreecommitdiff
path: root/numeric.c
diff options
context:
space:
mode:
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/numeric.c b/numeric.c
index fb9b28bcb3..7495b11095 100644
--- a/numeric.c
+++ b/numeric.c
@@ -2695,9 +2695,9 @@ num_step_check_fix_args(int argc, VALUE *to, VALUE *step, VALUE by, int fix_nil,
if (argc > 1 && NIL_P(*step)) {
rb_raise(rb_eTypeError, "step must be numeric");
}
- if (!allow_zero_step && rb_equal(*step, INT2FIX(0))) {
- rb_raise(rb_eArgError, "step can't be 0");
- }
+ }
+ if (!allow_zero_step && rb_equal(*step, INT2FIX(0))) {
+ rb_raise(rb_eArgError, "step can't be 0");
}
if (NIL_P(*step)) {
*step = INT2FIX(1);
@@ -2801,6 +2801,9 @@ num_step(int argc, VALUE *argv, VALUE from)
if (NIL_P(step)) {
step = INT2FIX(1);
}
+ else if (rb_equal(step, INT2FIX(0))) {
+ rb_raise(rb_eArgError, "step can't be 0");
+ }
if ((NIL_P(to) || rb_obj_is_kind_of(to, rb_cNumeric)) &&
rb_obj_is_kind_of(step, rb_cNumeric)) {
return rb_arith_seq_new(from, ID2SYM(rb_frame_this_func()), argc, argv,