errors and warnings / parsing / E0115
E0115 error
class, enum, declare or overload function not at the top level of a file
- area
- parsing (x01xx)
- fails the build
- yes
A class, abstract class, enum, declare or overload function stands
inside a block (a function, if, loop or do). They may only appear at the
top level of a file: each class and enum is exactly one runtime table, and
declarations and overloads describe the file's top-level names. Move the
declaration to the top level. (type and interface may appear in any
block.)
Example
local function setup() enum Mode { Simple, Advanced } return Mode.Simpleendprint(setup())enum Mode { Simple, Advanced } local function setup() return Mode.Simpleendprint(setup())The compiler reports it like this:
error[E0115]: `enum` is only allowed at the top level of a file ┌─ src/main.wowlua:2:5 │ 2 │ enum Mode { Simple, Advanced } │ ^^^^ here
Related codes
| code | message |
|---|---|
| E0108 | import / export not at the top level of a module |
Offline
$ wowlua explain E0115 E0115 (error): class, enum, declare or overload function not at the top level of a file