v0.13.7
errors and warnings / parsing

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

× failswowlua
local function setup()    enum Mode { Simple, Advanced }    return Mode.Simpleendprint(setup())
✓ compileswowlua
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
codemessage
E0108import / export not at the top level of a module

Offline

terminal
$ wowlua explain E0115
E0115 (error): class, enum, declare or overload function not at the top level of a file

source on GitHub ↗