errors and warnings / names / W1005
W1005 warning
Unreachable code
- area
- names (x1xxx)
- fails the build
- with --deny-warnings
Code follows a statement that execution never gets past: a do return end
(or break, continue), an if whose every branch returns or breaks, or a
call that never returns, such as error(…). The code after it can never run.
Remove it, or move it before the statement that leaves.
Example
local function sign(x: number): number if x >= 0 then return 1 else return -1 end print("never printed")endprint(sign(2))local function sign(x: number): number print("checking", x) if x >= 0 then return 1 else return -1 endendprint(sign(2))The compiler reports it like this:
warning[W1005]: unreachable code ┌─ src/main.wowlua:3:5 │ 3 │ print("never printed") │ ^^^^^^^^^^^^^^^^^^^^^^ here
Offline
$ wowlua explain W1005 W1005 (warning): Unreachable code