Bug: wrong result for (-0.0 - 0)

(exp - i) was being optimized to (exp + (-i)), to use OP_ADDI, but
(-0.0 - 0) is -0.0, while (-0.0 + 0) is +0.0, so the case (exp - 0)
was excluded from the optimization.
This commit is contained in:
Roberto I
2026-10-12 16:27:02 -03:00
parent 6db80b55c1
commit b35736b9d7
2 changed files with 10 additions and 1 deletions
+5
View File
@@ -838,6 +838,11 @@ do
local a1, a2, a3, a4, a5 = 0, 0, "\0\0\0\0\0\0\0\0", 0, "\0\0\0\0\0\0\0\0"
assert(a1 == a2 and a2 == a4 and a1 ~= a3)
assert(a3 == a5)
-- Bug since 5.4: Results differ for constant 0 versus variable 0;
-- (mz - 0) should be -0.0, but it resulted in +0.0
local zi = 0
assert(1/(mz - 0) == 1/(mz - zi))
end