Vector3 equality bug

NaN is not equal to NaN:

NaN = 0 / 0
print(NaN == NaN) -- false

This is according to how IEEE defines floating arithmetic.

Normally, Vector3s respect this:

NaN = 0/0
print(Vector3.new(NaN, 2, 3) == Vector3.new(NaN, 2, 3)) -- false

a = Vector3.new(NaN, 2, 3)
print(a + Vector3.new() == a) -- false

However, when comparing the same object to itself, this check returns true:

NaN = 0/0
a = Vector3.new(NaN, 0, 0)
print(a == a) -- true

That is, == incorrectly short circuits when this is compared to this in the C++ end. I’m guessing it looks something like this:

bool operator==(Vector3 &other) {
    if (&other == this) {
        return true; // THIS IS WRONG
    }
    return other.x == x && other.y == y && other.z == z;
}

This breaks the useful idiom of

function isNaN(x)
    return x ~= x
end

and is overall incredibly inconsistent.