gglresearchanddevelopment/ironlanguages-main — comment on commit 630995eca293b5b0531e821b76bab7e15c4506f6
File: Languages/Ruby/Libraries/Builtins/ExceptionOps.cs line 182
By tmat:

This doesn't seem to be quite right.
Unfortunately Ruby's exception object might be a bit messed up. Message might not be a string, backtrace is always an array (or nil) but it might not containg strings. It seems that Ruby calls "==" on the message object and then on each item of the backtrace.

It doesn't look like Ruby is comparing exception classes.

Also an exception can be compared with any object that has "message" and "backtrace" methods.

---

class C
def message
"hello"
end

def backtrace
["1","2","3"]
end
end

class D
def ==(other)
p "=="
true
end
end

c = C.new
m = D.new
e = Exception.new(m)
a = ["1","2","3"]
e.set_backtrace(a)
a[1] = D.new

p e == c

p e.backtrace.inspect, e.message
p c.backtrace.inspect, c.message

p IOError.new("1") == Exception.new("1")