v0.13.8
errors and warnings / types

errors and warnings / types / W2040

W2040 warning

Forbidden operation on a possibly secret value (basic mode)

area
types (x2xxx)
fails the build
with --deny-warnings

The basic-mode warning for E2040: the value may be a secret value, and this operation raises an error on one in game (arithmetic, comparison, #, indexing, calling, use as a table key, testing a secret boolean). It is a warning in basic mode and in plain Lua files, an error under --!strict. Narrow the value with canaccessvalue(v) or not issecretvalue(v) first.

Example

× failswowlua
local hp = UnitHealth("target")if hp < 1000 then    print("low")end
✓ compileswowlua
local hp = UnitHealth("target")if canaccessvalue(hp) and hp < 1000 then    print("low")end

The compiler reports it like this:

warning[W2040]: `number | Secret<number>` may be a secret value; narrow it with `canaccessvalue` or `issecretvalue` first
  ┌─ src/main.wowlua:2:4
  │
2 │ if hp < 1000 then
  │    ^^ here
codemessage
E2040Forbidden operation on a possibly secret value (strict mode)

Offline

terminal
$ wowlua explain W2040
W2040 (warning): Forbidden operation on a possibly secret value (basic mode)

source on GitHub ↗