errors and warnings / names / E1039
E1039 error
@if(flavor …) in a .wowlua file in shared flavor mode
- area
- names (x1xxx)
- fails the build
- yes
- in plain Lua files
- reported as W1039
@if(flavor …) is used in a .wowlua file in shared flavor mode
(build.flavor-mode = "shared"). There, one build runs on every flavor, so
flavor is a value known only in game and can't remove declarations at
compile time. Test the flavor at run time instead (if flavor == "standard" then … end), or switch to split mode, where each flavor gets its own build.
In declaration files @if(flavor …) keeps its meaning.
Example
{ "package": { "name": "playground", "version": "0.1.0", "wowlua": "^0.13" }, "flavors": { "camelot": {}, "standard": {} }, "build": { "flavor-mode": "shared" }}import flavor from "wowlua:meta" @if(flavor == "standard")local function setupEditMode() print("edit mode")end setupEditMode(){ "package": { "name": "playground", "version": "0.1.0", "wowlua": "^0.13" }, "flavors": { "camelot": {}, "standard": {} }, "build": { "flavor-mode": "shared" }}import flavor from "wowlua:meta" local function setupEditMode() print("edit mode")end if flavor == "standard" then setupEditMode()endThe compiler reports it like this:
error[E1039]: `flavor` is not a constant in shared flavor mode; use a runtime check ┌─ src/main.wowlua:3:5 │ 3 │ @if(flavor == "standard") │ ^^^^^^^^^^^^^^^^^^^^ here
Related codes
| code | message |
|---|---|
| E1040 | @if condition is not a static condition |
| E1020 | Reference to a declaration removed by @if or static elimination |
Offline
$ wowlua explain E1039 E1039 (error): @if(flavor …) in a .wowlua file in shared flavor mode