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

continue statement usage with return statement causes a syntax error #460

Open
xiaoandtell opened this issue Jan 13, 2025 · 0 comments
Open

Comments

@xiaoandtell
Copy link

Moonscript (main.lua):

-- print the first number divisible by 4
foo = () ->
	for i = 0, 40
		continue if not (i % 4 == 0)
		print i
		return
foo()

Compiled Lua:

foo = function()
  for i = 0, 40 do
    local _continue_0 = false
    repeat
      if not (i % 4 == 0) then
        _continue_0 = true
        break
      end
      print(i)
      return 
      _continue_0 = true
    until true
    if not _continue_0 then
      break
    end
  end
end
return foo()

error:

Error
Syntax error: main.lua:12: 'until' expected (to close 'repeat' at line 5) near '='
Traceback

[love "callbacks.lua"]:228: in function 'handler'
[C]: at 0x7ffc25e62fa0
[C]: in function 'require'
[C]: in function 'xpcall'
[C]: in function 'xpcall'
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

1 participant