object.c: move string to float conversion to `mrb_f_float`.
MODIFY
mrbgems/mruby-kernel-ext/src/kernel.c
mrbgems/mruby-kernel-ext/src/kernel.c
@@ -187,6 +187,9 @@ mrb_f_float(mrb_state *mrb, mrb_value self)
{
mrb_value arg = mrb_get_arg1(mrb);
+ if (mrb_string_p(arg)) {
+ return mrb_float_value(mrb, mrb_str_to_dbl(mrb, arg, TRUE));
+ }
return mrb_to_float(mrb, arg);
}
#endif

MODIFY
src/object.c
src/object.c
@@ -512,9 +512,6 @@ mrb_ensure_float_type(mrb_state *mrb, mrb_value val)
case MRB_TT_FLOAT:
return val;
- case MRB_TT_STRING:
- return mrb_float_value(mrb, mrb_str_to_dbl(mrb, val, TRUE));
-
default:
mrb_raisef(mrb, E_TYPE_ERROR, "%Y cannot be converted to Float", val);
/* not reached */

object.c: move string to float conversion to `mrb_f_float`.