Project

General

Profile

Actions

Bug #18236

closed

Conversion to float not working for object with to_f method

Added by toy (Ivan Kuchin) over 2 years ago. Updated about 1 year ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:105523]

Description

Following code works on all previous versions (1.8.7-p375, 1.9.3-p551, 2.0.0-p648, 2.1.10, 2.2.10, 2.4.10, 2.5.9, 2.6.8, 2.7.4), but not on 3.0 versions (3.0.0, 3.0.1, 3.0.2).

class Something
  def to_f
    0.1
  end
end

Thread.new{ }.join(Something.new)

On 3.0 it fails with:

test.rb:7:in `join': can't convert Something into Float (TypeError)
	from test.rb:7:in `<main>'

Thread#join uses rb_to_float which should handle object with to_f method (1, 2).

Discovered when digging into a PR submitted by @yahonda (Yasuo Honda)

Actions

Also available in: Atom PDF

Like0
Like0Like0