errors and warnings / names / E1037
E1037 error
Hoisted declaration used at load time before its definition has executed
- area
- names (x1xxx)
- fails the build
- yes
- in plain Lua files
- reported as W1037
A top-level function, class or enum of a module is used while the file
loads, before the line that defines it has run. They are hoisted, so other
functions can refer to them in any order, but the value is still nil until
its definition executes. Move the definition above the load-time use, or
move the use into code that runs later.
Example
export const VERSION = 1print(describe())function describe(): string return "v" .. VERSIONendexport const VERSION = 1function describe(): string return "v" .. VERSIONendprint(describe())The compiler reports it like this:
error[E1037]: `describe` is used before its definition runs (hoisted functions are `nil` until then) ┌─ src/main.wowlua:2:7 │ 2 │ print(describe()) │ ^^^^^^^^ here
Related codes
| code | message |
|---|---|
| E1014 | Import or usage cycle containing a load-time edge (run-time-only cycles are allowed) |
| W1034 | Name read at load time but only defined at run time |
Offline
$ wowlua explain E1037 E1037 (error): Hoisted declaration used at load time before its definition has executed