integer range check was moved to mrb_flo_to_fixnum(); ref #3025

This commit is contained in:
Yukihiro "Matz" Matsumoto
2015-11-19 03:12:42 +09:00
parent 09abdcb5e8
commit 996417cabf
2 changed files with 6 additions and 5 deletions
-4
View File
@@ -796,10 +796,6 @@ retry:
bin_retry:
switch (mrb_type(val)) {
case MRB_TT_FLOAT:
if (FIXABLE(mrb_float(val))) {
val = mrb_fixnum_value((mrb_int)mrb_float(val));
goto bin_retry;
}
val = mrb_flo_to_fixnum(mrb, val);
if (mrb_fixnum_p(val)) goto bin_retry;
break;
+6 -1
View File
@@ -964,7 +964,12 @@ mrb_flo_to_fixnum(mrb_state *mrb, mrb_value x)
if (isnan(d)) {
mrb_raise(mrb, E_FLOATDOMAIN_ERROR, "NaN");
}
z = (mrb_int)d;
if (FIXABLE(d)) {
z = (mrb_int)d;
}
else {
mrb_raisef(mrb, E_ARGUMENT_ERROR, "number (%S) too big for integer", x);
}
}
return mrb_fixnum_value(z);
}