v0.13.7
errors and warnings / names

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

× failssrc/main.wowluawowlua
import greet from "./other"export function hello(): string    return "hi"endprint(greet())
src/other.wowluawowlua
import hello from "./main"export function greet(): string    return hello() .. "!"endprint(greet())
✓ compilessrc/main.wowluawowlua
import greet from "./other"export function hello(): string    return "hi"endprint(greet())
src/other.wowluawowlua
import hello from "./main"export function greet(): string    return hello() .. "!"end

The 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
codemessage
W1034Name read at load time but only defined at run time
E1037Hoisted declaration used at load time before its definition has executed

Offline

terminal
$ wowlua explain E1014
E1014 (error): Import or usage cycle containing a load-time edge (run-time-only cycles are allowed)

source on GitHub ↗