From 8b43754644660c9dcdc6b8b18a1917f01e77479e Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Tue, 18 Sep 2018 09:35:09 +0900 Subject: Use `mrb_to_flo()` to check return value from `to_f`; fix #4115 The ISO standard does not include implicit type conversion using `to_int`, `to_str` and sometimes `to_f`. For the compactness of the mruby implementation, maybe we should remove those implicit conversion from mruby. --- mrbgems/mruby-pack/src/pack.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mrbgems/mruby-pack/src/pack.c b/mrbgems/mruby-pack/src/pack.c index 850462830..f970d9339 100644 --- a/mrbgems/mruby-pack/src/pack.c +++ b/mrbgems/mruby-pack/src/pack.c @@ -1127,7 +1127,8 @@ mrb_pack_pack(mrb_state *mrb, mrb_value ary) #ifndef MRB_WITHOUT_FLOAT } else if (type == PACK_TYPE_FLOAT) { if (!mrb_float_p(o)) { - o = mrb_funcall(mrb, o, "to_f", 0); + mrb_float f = mrb_to_flo(mrb, o); + o = mrb_float_value(mrb, f); } #endif } else if (type == PACK_TYPE_STRING) { -- cgit v1.2.3