Project

General

Profile

Backport #9238

Monkey Patching Float class Infix Operators Produces Unexpected Result

Added by screenmutt (Dan Grahn) almost 6 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Normal
[ruby-core:59027]

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

Related issues

Is duplicate of Ruby master - Bug #9237: Monkey Patching Infix Float Operator's Produces Unexpected ResultsClosed12/11/2013Actions

Associated revisions

Revision af4e6084
Added by marcandre (Marc-Andre Lafortune) almost 6 years ago

  • insns.def: Fix optimization bug of Float#/ [Bug #9238]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44127 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 44127
Added by marcandre (Marc-Andre Lafortune) almost 6 years ago

  • insns.def: Fix optimization bug of Float#/ [Bug #9238]

Revision 44127
Added by marcandre (Marc-Andre Lafortune) almost 6 years ago

  • insns.def: Fix optimization bug of Float#/ [Bug #9238]

Revision 44127
Added by marcandre (Marc-Andre Lafortune) almost 6 years ago

  • insns.def: Fix optimization bug of Float#/ [Bug #9238]

Revision 44127
Added by marcandre (Marc-Andre Lafortune) almost 6 years ago

  • insns.def: Fix optimization bug of Float#/ [Bug #9238]

Revision 44127
Added by marcandre (Marc-Andre Lafortune) almost 6 years ago

  • insns.def: Fix optimization bug of Float#/ [Bug #9238]

Revision 44127
Added by marcandre (Marc-Andre Lafortune) almost 6 years ago

  • insns.def: Fix optimization bug of Float#/ [Bug #9238]

Revision 86d9d122
Added by nagachika (Tomoyuki Chikanaga) over 5 years ago

merge revision(s) 44127: [Backport #9238]

    * insns.def: Fix optimization bug of Float#/ [Bug #9238]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@44326 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 44326
Added by nagachika (Tomoyuki Chikanaga) over 5 years ago

merge revision(s) 44127: [Backport #9238]

* insns.def: Fix optimization bug of Float#/ [Bug #9238]

History

Updated by screenmutt (Dan Grahn) almost 6 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) almost 6 years ago

I just saw this bug posted at https://bugs.ruby-lang.org/issues/9237. Please mark as duplicate.

#3

Updated by marcandre (Marc-Andre Lafortune) almost 6 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) almost 6 years ago

Cute bug.
You were lucky to figure out that redefining * "fixed" it!
Would have loved to mention that in my rubyconf talk :-)

#5

Updated by marcandre (Marc-Andre Lafortune) almost 6 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)
#6

Updated by nagachika (Tomoyuki Chikanaga) over 5 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]

Also available in: Atom PDF