v0.13.7
errors and warnings / classes

errors and warnings / classes / E3007

E3007 error

Metamethod on a widget class

area
classes (x3xxx)
fails the build
yes

A widget class (a class that extends a frame type such as Frame or Button) defines a metamethod such as __tostring or __eq. The frame's metatable belongs to WoW, so a widget class can't have metamethods. Use an ordinary method instead.

Example

× failswowlua
class Tile extends Frame    function __tostring(): string        return "tile"    endendprint(Tile)
✓ compileswowlua
class Tile extends Frame    function describe(): string        return "tile"    endendprint(Tile)

The compiler reports it like this:

error[E3007]: widget class `Tile` cannot define the metamethod `__tostring`
  ┌─ src/main.wowlua:2:14
  │
2 │     function __tostring(): string
  │              ^^^^^^^^^^ the frame's metatable belongs to WoW
codemessage
E3043Accessor declared on a widget class
E3004Reserved member name

Offline

terminal
$ wowlua explain E3007
E3007 (error): Metamethod on a widget class

source on GitHub ↗