errors and warnings / names / E1040
E1040 error
@if condition is not a static condition
- area
- names (x1xxx)
- fails the build
- yes
- in plain Lua files
- reported as W1040
An @if condition isn't static: it reads a runtime value such as a local,
or @if is given more than one condition. Conditions may use wowlua:meta
paths (flavor, build.debug, features.x, config.x), constants and
literals. On an import, only wowlua:meta paths and literals are allowed,
not consts, because each flavor's import graph is built before constants
are evaluated. For a runtime decision, use an ordinary if.
Example
local verbose = true @if(verbose)local function dumpState() print("state")endimport build from "wowlua:meta" @if(build.debug)local function dumpState() print("state")end if build.debug then dumpState()endThe compiler reports it like this:
error[E1040]: `@if` conditions must be static: `wowlua:meta` paths, constants and literals ┌─ src/main.wowlua:3:5 │ 3 │ @if(verbose) │ ^^^^^^^ here
Related codes
| code | message |
|---|---|
| E1039 | @if(flavor …) in a .wowlua file in shared flavor mode |
| E1020 | Reference to a declaration removed by @if or static elimination |
Offline
$ wowlua explain E1040 E1040 (error): @if condition is not a static condition