Open Davidobot opened 4 years ago
This is not a bug in love.js. Its a PUC Lua5.1 issue :(
Casting to strings in string.format
is not defined behaviour in Lua5.1. As with most undefined behaviour its treated differently between PUC and luajit implementations. PUC will only cast numbers as strings, while luajit, for compatibility with Lua5.2, will cast numbers, tables and bools as strings.
If you need to use a bool
in string.format, cast it to a string using tostring
.
string.format("%s", tostring(true))
But love2d uses luajit and not PUC Lua5.1, so that shouldn't be an issue here? Maybe something in love.js changes some compatibility flags that drops us back to the 5.1 behaviour?
Love2d supports PUC Lua5.1 by default. It is used on platforms that don't support luajit. By passing in the -LOVE_JIT=0
when building the megasource it reverts to using Lua 5.1 .
Unfortunately, using PUC Lua5.1 is necessary for APPLE and Emscripten builds as the core of luajit is platform specific assembly (not c or c++) . It would have to manually be ported to wasm.
If you want to try, you can remove the arg from the build script.
The absence of the jit global variable indicates that this version of love was not compiled with luajit.
I don't know anything about love.js internals, but I read something recently that's relevant:
According to this answer, it seems that Lua 5.2 calls a new C function luaL_tolstring which autoconverts booleans to strings. Maybe love.js is somehow not building with the right flag to include that version?