ID:2374996
 
Resolved
Datums that exactly matched did not handle the equivalence ~= and ~! operators correctly.
BYOND Version:512.1426
Operating System:Windows 10 Home 64-bit
Web Browser:Chrome 67.0.3396.62
Applies to:Dream Daemon
Status: Resolved (512.1427)

This issue has been resolved.
When checking the equivalence of an atom or datum with itself, the operator overload proc isn't called and the result is false. I would expect it to call the overload proc in all cases, and the default result should be true if the objects are actually equal.
mob/verb/test()
// Checking an object's equivalence to itself
// Bug: doesn't call the overload AND gives the opposite of a desired result
var thing/t = new
world.log << "Calling overload (bugged, doesn't actually call it)"
world.log << "[t ~= t] (0, should be 1)"
world.log << "Calling inverse overload (bugged, doesn't actually call it)"
world.log << "[t ~! t] (1, should be 0)"

world.log << ""

// Checking an object's equivalence with another
var thing/u = new
world.log << "Calling overload"
// Bug: Overload's called 4 times?
world.log << "[t ~= u] (0, should be 0)"
world.log << "Calling inverse overload"
world.log << "[t ~! u] (1, should be 1)"

thing/proc/operator~=(thing/t)
world.log << "Overload called"
return src == t
Lummox JR resolved issue with message:
Datums that exactly matched did not handle the equivalence ~= and ~! operators correctly.
Not calling the overloaded operator isn't really a bug but an optimization. However the code was handling this incorrectly, and a fallback case was taking over when it shouldn't have.

I considered pulling out the optimization so the overload is always called, but IMO I don't think it's at all a good idea to set a precedent where ~= can return false when comparing an object to itself, or likewise ~! return true.