v0.13.7
errors and warnings / types

errors and warnings / types / E2030

E2030 error

API not available in every flavor (shared flavor mode), missing a flavor guard

area
types (x2xxx)
fails the build
yes
in plain Lua files
reported as W2030

Shared flavor mode only ("build": { "flavor-mode": "shared" }): one build runs on several flavors, and this API doesn't exist on all of them. On a flavor without it, the name is nil in game, and using it raises an error. Guard the use with a flavor check (if flavor == "standard" then, a WOW_PROJECT_ID comparison) or an existence check (if C_Garrison then).

In a plain Lua file it is the warning W2030.

Example

× failswowlua.jsonjson
{    "package": { "name": "playground", "version": "0.1.0", "wowlua": "^0.13" },    "flavors": { "standard": {}, "vanilla": {} },    "build": { "flavor-mode": "shared" }}
src/main.wowluawowlua
--!strictC_Garrison.GetGarrisonInfo(1)
✓ compileswowlua.jsonjson
{    "package": { "name": "playground", "version": "0.1.0", "wowlua": "^0.13" },    "flavors": { "standard": {}, "vanilla": {} },    "build": { "flavor-mode": "shared" }}
src/main.wowluawowlua
--!strictif C_Garrison then    C_Garrison.GetGarrisonInfo(1)end

The compiler reports it like this:

error[E2030]: `C_Garrison.GetGarrisonInfo` is not available in `vanilla`; guard it with a flavor check or an existence check
  ┌─ src/main.wowlua:2:12
  │
2 │ C_Garrison.GetGarrisonInfo(1)
  │            ^^^^^^^^^^^^^^^ here
codemessage
W2030API not available in every flavor (shared flavor mode), missing a flavor guard (in a plain Lua file)

Offline

terminal
$ wowlua explain E2030
E2030 (error): API not available in every flavor (shared flavor mode), missing a flavor guard

source on GitHub ↗