D:\> ruby -v
ruby 2.2.3p147 (2015-07-04 revision 51143) [x64-mswin64_120]
D:\> ruby test.rb
test.rb:8:in `==': stack level too deep (SystemStackError)
from test.rb:8:in `=='
from test.rb:8:in `=='
from test.rb:8:in `=='
from test.rb:8:in `=='
from test.rb:8:in `=='
from test.rb:8:in `=='
from test.rb:8:in `=='
from test.rb:8:in `=='
... 2574 levels...
from test.rb:8:in `=='
from test.rb:8:in `=='
from test.rb:8:in `=='
from test.rb:17:in `<main>'
It seems to be a problem specific to Windows. The test suite passes (IIRC)
Should the result not be false instead?
These two instances each have a different @friend and it cannot be determined if they are equal so "false" seems a much safer answer.
Also, this seems inconsistent to how Comparable#== treat such cases:
class Something
attr_accessor :friend
def initialize(friend)
self.friend = friend
end
include Comparable
def <=>(other)
friend <=> other
end
end
a = Something.new([])
b = Something.new([a])
a.friend = [b]
p a == b # false (and not true like above!)