errors and warnings / classes / W3021
W3021 warning
Lexical binding named like a core decorator is not a re-export of it (ignored in decorator position)
- area
- classes (x3xxx)
- fails the build
- with --deny-warnings
A local or imported function has a core decorator's name (profile, trace,
…) but isn't a re-export of that decorator. In decorator position a core
decorator's name always means the core decorator, so @profile ignores your
function; the warning is reported where @profile is written. Import it under another name (import profile as myProfile from "./perf") and write @myProfile. Re-exports such as import profile from "wowlua:debug" are fine.
Example
local function profile(fn: () -> (), _ctx: DecoratorContext) return fnend @profilelocal function refresh()endrefresh()print(profile)local function measured(fn: () -> (), _ctx: DecoratorContext) return fnend @measuredlocal function refresh()endrefresh()The compiler reports it like this:
warning[W3021]: `@profile` is the core decorator: the function `profile` in scope is not used here ┌─ src/main.wowlua:5:1 │ 5 │ @profile │ ^^^^^^^^ the core decorator │ = help: to decorate with your function, import it under another name (`import profile as myProfile from …`) and write that name
Related codes
| code | message |
|---|---|
| E3020 | Unknown decorator |
Offline
$ wowlua explain W3021 W3021 (warning): Lexical binding named like a core decorator is not a re-export of it (ignored in decorator position)