summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--numeric.c18
2 files changed, 21 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 8b76a9f349..dc85786c9c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue Sep 3 07:31:29 2013 Akinori MUSHA <knu@iDaemons.org>
+
+ * 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 <akr@fsij.org>
* internal.h (bit_length): Add casts to fix complation error with
diff --git a/numeric.c b/numeric.c
index 04e2bcbd2e..57b61759c1 100644
--- a/numeric.c
+++ b/numeric.c
@@ -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); \