errors and warnings / types / W2060
W2060 warning
Division or modulo by a literal zero: WoW raises "Division by zero" (any mode)
- area
- types (x2xxx)
- fails the build
- with --deny-warnings
Division or modulo by a literal zero (or a const of it). Elsewhere Lua gives
inf or nan, but WoW raises "Division by zero". Use math.huge for infinity,
and guard a divisor that can be zero at run time (if max > 0 then); the
checker can't see those.
Example
local function half(n: number): number return n / 0endprint(half(1))local function half(n: number): number return n / 2endprint(half(1))The compiler reports it like this:
warning[W2060]: division by zero: WoW raises an error here, where Lua elsewhere gives inf or nan (use `math.huge` for infinity) ┌─ src/main.wowlua:2:16 │ 2 │ return n / 0 │ ^ here
Offline
$ wowlua explain W2060 W2060 (warning): Division or modulo by a literal zero: WoW raises "Division by zero" (any mode)