v0.13.7
errors and warnings / stdlib

errors and warnings / stdlib / W8102

W8102 warning

Hook target belongs to a load-on-demand addon but opts.addon is missing

area
stdlib (x8xxx)
fails the build
with --deny-warnings

The hook's target belongs to one of Blizzard's load-on-demand addons (such as Blizzard_AchievementUI) and exists only once that addon has loaded. Hooked without opts.addon, the hook runs too early and fails, or finds nothing.

Pass { addon = "<AddOn>" } so the hook waits for the addon to load, and name the target as a string so it is looked up then. A global function is hooked as hook(_G, "Name", fn, { addon = … }). An if test around the hook doesn't help here: before the addon loads the test fails and the hook is never installed.

Example

× failswowlua
import hook from "wowlua:hooks"hook("AchievementFrame_ToggleAchievementFrame", function() print("toggled") end)
✓ compileswowlua
import hook from "wowlua:hooks"hook(_G, "AchievementFrame_ToggleAchievementFrame", function() print("toggled") end, { addon = "Blizzard_AchievementUI" })

The compiler reports it like this:

warning[W8102]: `AchievementFrame_ToggleAchievementFrame` exists only once the load-on-demand addon `Blizzard_AchievementUI` has loaded; hook it with `hook(_G, "AchievementFrame_ToggleAchievementFrame", fn, { addon = "Blizzard_AchievementUI" })`
  ┌─ src/main.wowlua:2:6
  │
2 │ hook("AchievementFrame_ToggleAchievementFrame", function() print("toggled") end)
  │      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ here
codemessage
W8040Hook target not declared (not reported inside an existence test of the same member, if obj.Method then)

Offline

terminal
$ wowlua explain W8102
W8102 (warning): Hook target belongs to a load-on-demand addon but opts.addon is missing

source on GitHub ↗