Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

goto statements cause a syntax error in love.js #77

Open
akseliv opened this issue Jan 31, 2023 · 4 comments
Open

goto statements cause a syntax error in love.js #77

akseliv opened this issue Jan 31, 2023 · 4 comments

Comments

@akseliv
Copy link

akseliv commented Jan 31, 2023

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)

@mvolkmann
Copy link

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.

@ParticleG
Copy link

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.

Apparently LuaJIT supports goto, and Love2D supports it too. luajit.org/extensions.html

@rbaltrusch
Copy link

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 👍

@alexjgriffith
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants