errors and warnings / names / E1014
E1014 error
Import or usage cycle containing a load-time edge (run-time-only cycles are allowed)
- area
- names (x1xxx)
- fails the build
- yes
- in plain Lua files
- reported as W1014
Files depend on each other in a cycle, and at least one dependency is needed while a file loads. WoW loads files one after another, so one of them would run before the other has defined what it uses. Modules may import each other as long as the uses only happen later (inside functions called from events, timers or handlers); a top-level call is what makes a use load-time. The message shows the cycle and the calls that lead to each load-time use. Move the use into a function that runs later, or move the shared code into a third module.
Example
import greet from "./other"export function hello(): string return "hi"endprint(greet())import hello from "./main"export function greet(): string return hello() .. "!"endprint(greet())import greet from "./other"export function hello(): string return "hi"endprint(greet())import hello from "./main"export function greet(): string return hello() .. "!"endThe compiler reports it like this:
error[E1014]: load-time dependency cycle between main.wowlua, other.wowlua ┌─ src/main.wowlua:5:7 │ 5 │ print(greet()) │ ^^^^^ `main.wowlua` uses the import `greet` from `other.wowlua` while it loads │ ┌─ src/other.wowlua:3:12 │ 3 │ return hello() .. "!" │ ----- `other.wowlua` uses the import `hello` from `main.wowlua` while it loads │ = note: main.wowlua: in top-level code = note: other.wowlua: in greet, called from top-level code = help: move the use into a function that runs later (an event handler, for example), or split a module
Related codes
| code | message |
|---|---|
| W1034 | Name read at load time but only defined at run time |
| E1037 | Hoisted declaration used at load time before its definition has executed |
Offline
$ wowlua explain E1014 E1014 (error): Import or usage cycle containing a load-time edge (run-time-only cycles are allowed)