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
+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);
}