v0.13.7
errors and warnings / parsing

errors and warnings / parsing / E0106

E0106 error

continue or break outside a loop

area
parsing (x01xx)
fails the build
yes

A break or continue is not inside a loop of the same function. Both only leave or restart the innermost while, repeat or for loop; a loop around the function that contains them doesn't count. Use return to leave a function early.

Example

× failswowlua
local function onEvent(event: string)    if event ~= "PLAYER_LOGIN" then        break    end    print("logged in")endonEvent("PLAYER_LOGIN")
✓ compileswowlua
local function onEvent(event: string)    if event ~= "PLAYER_LOGIN" then        return    end    print("logged in")endonEvent("PLAYER_LOGIN")

The compiler reports it like this:

error[E0106]: no loop to break near 'end'
  ┌─ src/main.wowlua:3:9
  │
3 │         break
  │         ^^^^^ here
codemessage
E0114continue is not the last statement of its block

Offline

terminal
$ wowlua explain E0106
E0106 (error): continue or break outside a loop

source on GitHub ↗