Backport #9238
closedMonkey Patching Float class Infix Operators Produces Unexpected Result
Description
Hello!
Patching Float class infix operators seem to work only if 2 are present. See the code below.
class Float
def /(other)
"magic"
end
end
first_result = 10.0 / 2.0
class Float
def *(other)
"weird"
end
end
second_result = 10.0 / 2.0
if first_result == 5.0 && second_result == "magic"
puts "Bug confirmed"
else
puts "Bug not present"
end
Updated by screenmutt (Dan Grahn) about 11 years ago
I just saw this bug posted at https://bugs.ruby-lang.org/issues/9237. Please mark as duplicate.
Updated by screenmutt (Dan Grahn) about 11 years ago
I just saw this bug posted at https://bugs.ruby-lang.org/issues/9237. Please mark as duplicate.
Updated by marcandre (Marc-Andre Lafortune) about 11 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
This issue was solved with changeset r44127.
Dan, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
- insns.def: Fix optimization bug of Float#/ [Bug #9238]
Updated by marcandre (Marc-Andre Lafortune) about 11 years ago
Cute bug.
You were lucky to figure out that redefining * "fixed" it!
Would have loved to mention that in my rubyconf talk :-)
Updated by marcandre (Marc-Andre Lafortune) about 11 years ago
- Tracker changed from Bug to Backport
- Project changed from Ruby master to Backport200
- Status changed from Closed to Open
- Assignee set to nagachika (Tomoyuki Chikanaga)
Updated by nagachika (Tomoyuki Chikanaga) about 11 years ago
- Status changed from Open to Closed
This issue was solved with changeset r44326.
Dan, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
merge revision(s) 44127: [Backport #9238]
* insns.def: Fix optimization bug of Float#/ [Bug #9238]