Check if `to_int` returns `fixnum` value; fix #3946

parent ef1a0e63
......@@ -569,8 +569,8 @@ arg_error:
mrb_raise(mrb, E_ARGUMENT_ERROR, "base specified for non string value");
}
tmp = convert_type(mrb, val, "Integer", "to_int", FALSE);
if (mrb_nil_p(tmp)) {
return mrb_to_integer(mrb, val, "to_i");
if (mrb_nil_p(tmp) || !mrb_fixnum_p(tmp)) {
tmp = mrb_to_integer(mrb, val, "to_i");
}
return tmp;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment