Closed sir-maniac closed 1 year ago
Another interesting issue with PUC lua5.1(linux):
> =string.format("%d", 0/0)
-9223372036854775808
> =("%d").format(0/0)
-nan
Another possibly-related issue:
print(-0.0)
prints -0 on versions of PUC Lua before 5.3, -0.0 on versions of PUC Lua after/including 5.3, but 0 on Cobalt
Another interesting issue with PUC lua5.1(linux):
> =string.format("%d", 0/0) -9223372036854775808 > =("%d").format(0/0) -nan
shouldn't the
("%d").format
be("%d"):format
here?
A compatibility edge case was discovered during discussion here, so adding this issue for reference.
I think the best way to handle this is to modify StringFormat, as I think
LuaValue.checkLong
should return the value it currently returns. So a check if the value is double, and if so, either callDouble.doubleToLongBits
(lua 5.1), or signal an error (lua 5.3).https://github.com/SquidDev/Cobalt/blob/2cec621e10982ed98024952daa138ce13ad718d9/src/main/java/org/squiddev/cobalt/lib/StringFormat.java#L79-L86