errors and warnings / stdlib / E8118
E8118 error
wowlua:log level function used as a value (cannot be stripped)
- area
- stdlib (x8xxx)
- fails the build
- yes
A wowlua:log level function (trace, debug, info, warn, error) is
used as a value instead of being called, whether imported by name or read
from the log object or a namespace import (local f = log.warn,
Log.debug). The compiler removes log calls below
the profile's log-level, with their arguments, so they cost nothing in a
release build. It can do that only for direct calls, never for a function that
was stored in a variable or passed along. Wrap the call in your own function.
Example
import warn from "wowlua:log" local report = warnreport("low on bag space")import warn from "wowlua:log" local function report(message: string) warn(message)endreport("low on bag space")The compiler reports it like this:
error[E8118]: a log level function can only be called directly, so that the compiler can remove it; wrap it in a function ┌─ src/main.wowlua:3:16 │ 3 │ local report = warn │ ^^^^ here
Related codes
| code | message |
|---|---|
| E3045 | Statement-only wowlua:debug helper used as a value |
Offline
$ wowlua explain E8118 E8118 (error): wowlua:log level function used as a value (cannot be stripped)