v0.13.7
errors and warnings / names

errors and warnings / names / W1035

W1035 warning

Usage-analysis dependency contradicts build.load-order; the listed order is kept (contradicting imports are E1035)

area
names (x1xxx)
fails the build
with --deny-warnings

build.load-order lists a file before one whose definitions it uses while loading, as found by usage analysis (globals, addon-namespace fields). The listed order wins, because the analysis can over-approximate without types and wowlua init writes the order of a TOC that worked. If the warning is right, reorder the list; if the use really happens later, the warning can be silenced in check.lints.

Example

× failswowlua.jsonjson
{    "package": { "name": "playground", "version": "0.1.0", "wowlua": "^0.13" },    "flavors": { "camelot": {} },    "build": { "load-order": ["src/main.lua", "src/util.lua"] }}
src/main.lualua
print(MyAddonGreeting)
src/util.lualua
MyAddonGreeting = "hi"
✓ compileswowlua.jsonjson
{    "package": { "name": "playground", "version": "0.1.0", "wowlua": "^0.13" },    "flavors": { "camelot": {} },    "build": { "load-order": ["src/util.lua", "src/main.lua"] }}
src/main.lualua
print(MyAddonGreeting)
src/util.lualua
MyAddonGreeting = "hi"

The compiler reports it like this:

warning[W1035]: `build.load-order` loads `main.lua` before `util.lua`, which uses a name it defines; keeping the listed order
  ┌─ src/main.lua:1:7
  │
1 │ print(MyAddonGreeting)
  │       ^^^^^^^^^^^^^^^ `main.lua` uses `MyAddonGreeting` from `util.lua` while it loads
  │
  = help: if the listed order is wrong, change `build.load-order`; otherwise move the use into a function that runs later
codemessage
E1035build.load-order contradicts a computed load-time dependency
W1033Load order cannot be determined (dynamic names, several writers, external names); files keep their source order

Offline

terminal
$ wowlua explain W1035
W1035 (warning): Usage-analysis dependency contradicts build.load-order; the listed order is kept (contradicting imports are E1035)

source on GitHub ↗