Project

General

Profile

Actions

Bug #18236

closed

Conversion to float not working for object with to_f method

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

Status:
Closed
Priority:
Normal
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 #1

Updated by nobu (Nobuyoshi Nakada) about 1 year ago

  • Status changed from Open to Closed

Applied in changeset git|19f9d9cf739e7fc185ef90d5da5b4b12cf902a52.


Remove extraneous conversion to float [Bug #18236]

Actions

Also available in: Atom PDF

Like0
Like0