v0.13.7
errors and warnings / stdlib

errors and warnings / stdlib / E8350

E8350 error

@binding / header not at module top level, or with non-constant arguments

area
stdlib (x8xxx)
fails the build
yes

wowlua:bindings declarations are collected at compile time to generate Bindings.xml, so they must be fixed when the addon is built. @binding is allowed only on a top-level function declaration, with the binding's name as a constant string and the header, default and runOnUp options as constants in a table literal (label may be any string, such as a locale entry). header(id, label) must be a statement at the module's top level, with a constant id. A constant is a literal or a top-level const of the file.

Example

× failswowlua
import binding from "wowlua:bindings" local name = "MYADDON_TOGGLE" @binding(name, { label = "Toggle window" })local function toggleWindow()    print("toggle")end
✓ compileswowlua
import binding from "wowlua:bindings" const NAME = "MYADDON_TOGGLE" @binding(NAME, { label = "Toggle window" })local function toggleWindow()    print("toggle")end

The compiler reports it like this:

error[E8350]: `@binding` needs the binding's name as a constant string
  ┌─ src/main.wowlua:5:10
  │
5 │ @binding(name, { label = "Toggle window" })
  │          ^^^^ not a constant
codemessage
E8351Duplicate keybinding name in the addon
E8352Invalid keybinding name (must match [A-Z][A-Z0-9_]*)

Offline

terminal
$ wowlua explain E8350
E8350 (error): @binding / header not at module top level, or with non-constant arguments

source on GitHub ↗