v0.13.7
errors and warnings / classes

errors and warnings / classes / E3032

E3032 error

Invalid @debugOnly function (returns values, or a call is used as an expression)

area
classes (x3xxx)
fails the build
yes

A @debugOnly function is used in a way that can't be removed. Release builds remove the function and every call statement to it, so it can't return values and its calls can't be used as values (local x = report(1)). Make it return nothing, and call it on its own line. A use as a value is reported in every build, also where debug keeps the function, but not in code that only debug builds keep (if build.debug then … end, @if(build.debug)).

Example

× failswowlua
@debugOnlylocal function check(n: number): boolean    return n > 0endcheck(1)
× failswowlua
@debugOnlylocal function report(n: number)    print(n)endC_Timer.After(1, function() report(1) end)local later = report
✓ compileswowlua
@debugOnlylocal function report(n: number)    print(n)endreport(1)

The compiler reports it like this:

error[E3032]: a `@debugOnly` function cannot return values (its calls are removed from release builds)
  ┌─ src/main.wowlua:3:5
  │
3 │     return n > 0
  │     ^^^^^^^^^^^^ here
codemessage
E3045Statement-only wowlua:debug helper used as a value

Offline

terminal
$ wowlua explain E3032
E3032 (error): Invalid @debugOnly function (returns values, or a call is used as an expression)

source on GitHub ↗