v0.13.7
errors and warnings / names

errors and warnings / names / E1001

E1001 error

Undefined global read (strict mode)

area
names (x1xxx)
fails the build
yes
in plain Lua files
reported as W1001

In strict mode, the code reads a global that nothing declares: no WoW API, Lua library, declare global, SavedVariable from the manifest, check.globals entry, or global that a file of the package assigns. Most often it is a typo or a missing local; in game the read gives nil and fails later with "attempt to call/index a nil value". Fix the name, make it a local or an import, or declare the global (declare global name: T).

Strict mode comes from --!strict or the manifest (check.mode, check.strict). In basic mode, the default, the same read is the warning W1001. An existence test (if SomeApi then … end) never reports the tested name.

Example

× failswowlua
--!strictlocal playerName = UnitName("player")print(playerNmae)
✓ compileswowlua
--!strictlocal playerName = UnitName("player")print(playerName)

The compiler reports it like this:

error[E1001]: `playerNmae` is not a declared global
  ┌─ src/main.wowlua:3:7
  │
3 │ print(playerNmae)
  │       ^^^^^^^^^^ here
codemessage
W1001Undefined global read (basic mode)
E1002Implicit global assignment (strict mode)

Offline

terminal
$ wowlua explain E1001
E1001 (error): Undefined global read (strict mode)

source on GitHub ↗