errors and warnings / names / E1002
E1002 error
Implicit global assignment (strict mode)
- area
- names (x1xxx)
- fails the build
- yes
- in plain Lua files
- reported as W1002
In strict mode, the code assigns a global that isn't declared, including
through function name() in a script. Accidental globals are a classic addon
bug: they leak into every addon's environment, can collide with other addons'
names and can taint Blizzard code. Make it local if only this file needs
it, export it from a module, or declare a real global (declare global name: T). Writing _G.name = value is always allowed.
In basic mode the same assignment is the warning W1002.
Example
--!strictcounter = 0--!strictdeclare global MyAddonCounter: numberMyAddonCounter = 0The compiler reports it like this:
error[E1002]: assigns the undeclared global `counter` (declare it, use `_G.counter`, or make it `local`) ┌─ src/main.wowlua:2:1 │ 2 │ counter = 0 │ ^^^^^^^ here
Related codes
Offline
$ wowlua explain E1002 E1002 (error): Implicit global assignment (strict mode)