v0.13.7
errors and warnings / names

errors and warnings / names / W1002

W1002 warning

Implicit global assignment (basic mode)

area
names (x1xxx)
fails the build
with --deny-warnings

The code assigns a global that isn't declared (see E1002). It is a warning in basic mode, the default, and in plain Lua files; strict mode makes it the error E1002. If the global is meant to exist (a SavedVariable, an API for other addons), declare it or write _G.name = value; otherwise make it local.

Example

× failswowlua
counter = 0
✓ compileswowlua
local counter = 0print(counter)

The compiler reports it like this:

warning[W1002]: assigns the undeclared global `counter` (declare it, use `_G.counter`, or make it `local`)
  ┌─ src/main.wowlua:1:1
  │
1 │ counter = 0
  │ ^^^^^^^ here
codemessage
E1002Implicit global assignment (strict mode)
W1001Undefined global read (basic mode)

Offline

terminal
$ wowlua explain W1002
W1002 (warning): Implicit global assignment (basic mode)

source on GitHub ↗