Skip to content

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

Open
@xiaoandtell

Description

@xiaoandtell

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'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions