love.js
love.js copied to clipboard
goto statements cause a syntax error in love.js
Error: Syntax error: main.lua:362: '=' expected near 'continue'
is thrown for this valid Lua code
goto continue
(as Lua lacks a 'continue' statement, goto is typically the next best thing)
The goto statement was added in Lua 5.2. As far as I can tell, LuaJIT does not support that and love2d uses LuaJIT. So I think you need to rewrite you code using an if statement so that goto isn't needed. I ran into the same problem and solve it by doing just that.
The
gotostatement was added in Lua 5.2. As far as I can tell, LuaJIT does not support that and love2d uses LuaJIT. So I think you need to rewrite you code using anifstatement so thatgotoisn't needed. I ran into the same problem and solve it by doing just that.
Apparently LuaJIT supports goto, and Love2D supports it too. luajit.org/extensions.html
I have also noticed this issue. According to this stackoverflow thread, the goto statement exists in LuaJIT since v2.0.1 and Lua since 5.2. Although goto should typically be avoided in well-written code, continue allows early exit of loops - having to avoid constructs like if my_early_exit then goto continue end is a significant blow to the usefulness of love.js - hope this issue gets fixed :+1:
This is a repeat of #62
As pointed out above, goto was only introduced in Lua 5.2. Luajit adopted the feature.
Since there is no wasm support for luajit, the web target relies on Lua 5.1. There is no fix, short of getting luajit to target wasm. When using the web port make sure to stick to Lua 5.1 syntax / semantics.