Make mrb_to_flo() to convert objects, not integer, not float; #5268

Thinking `Ratinal` and `Complex` in mind.
This commit is contained in:
Yukihiro "Matz" Matsumoto
2021-01-17 22:53:54 +09:00
parent 126f0f0563
commit b4817a54f0
+6 -1
View File
@@ -39,8 +39,13 @@ mrb_to_flo(mrb_state *mrb, mrb_value val)
return (mrb_float)mrb_integer(val);
case MRB_TT_FLOAT:
break;
default:
case MRB_TT_STRING:
case MRB_TT_FALSE:
case MRB_TT_TRUE:
mrb_raise(mrb, E_TYPE_ERROR, "non float value");
default:
val = mrb_type_convert(mrb, val, MRB_TT_FLOAT, MRB_SYM(to_f));
break;
}
return mrb_float(val);
}