Skip to content

Commit

Permalink
[Truffle] ActiveSupport::Duration patches instance_of? therefore we h…
Browse files Browse the repository at this point in the history
…ave to use comparison of classes
pitr-ch committed Mar 1, 2016

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 937d51f commit 5448801
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion truffle/src/main/ruby/core/rubinius/common/numeric.rb
Original file line number Diff line number Diff line change
@@ -45,7 +45,7 @@ def divmod(other)
end

def eql?(other)
return false unless other.instance_of? self.class
return false unless other.class == self.class
self == other
end

4 comments on commit 5448801

@nirvdrum
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They patch it in a non-compatible way?

@pitr-ch
Copy link
Member Author

@pitr-ch pitr-ch commented on 5448801 Mar 1, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a_duration.instance_of? Fixnum #=> true which leads to eql? behaving wrongly as ==. 1.eql?(1.second) should be false and 1 == 1.second should be true.

@nirvdrum
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh. Thanks for clarifying.

@eregon
Copy link
Member

@eregon eregon commented on 5448801 Mar 2, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is some stuff in Rubinius::Type to avoid redefinition, like object_instance_of?. This fix seems good enough though. (it would require to redefine #class or Class#== to break).

Please sign in to comment.