diff --git a/kernel.rb b/kernel.rb index de20fffcf9..9cc58bc1d9 100644 --- a/kernel.rb +++ b/kernel.rb @@ -169,6 +169,10 @@ module Kernel # Float("123.0_badstring", exception: false) #=> nil # def Float(arg, exception: true) - Primitive.rb_f_float(arg, exception) + if Primitive.mandatory_only? + Primitive.rb_f_float1(arg) + else + Primitive.rb_f_float(arg, exception) + end end end diff --git a/object.c b/object.c index f98fb83936..755645b76e 100644 --- a/object.c +++ b/object.c @@ -3531,6 +3531,12 @@ rb_Float(VALUE val) return rb_convert_to_float(val, TRUE); } +static VALUE +rb_f_float1(rb_execution_context_t *ec, VALUE obj, VALUE arg) +{ + return rb_convert_to_float(arg, TRUE); +} + static VALUE rb_f_float(rb_execution_context_t *ec, VALUE obj, VALUE arg, VALUE opts) {