v0.13.7
errors and warnings / types

errors and warnings / types / E2008

E2008 error

Method called without self (use :)

area
types (x2xxx)
fails the build
yes
in plain Lua files
reported as W2008

A method is called with . instead of :, so it gets no self, and in game its first line that reads self raises an error. Call it with : (c:bump()), or pass the receiver yourself (c.bump(c)). Static methods take no self and are called with ..

Example

× failswowlua
class Counter    n: number = 0    function bump()        self.n += 1    endendlocal c = Counter.new()c.bump()
✓ compileswowlua
class Counter    n: number = 0    function bump()        self.n += 1    endendlocal c = Counter.new()c:bump()

The compiler reports it like this:

error[E2008]: `bump` is a method; call it with `:`
  ┌─ src/main.wowlua:8:1
  │
8 │ c.bump()
  │ ^^^^^^^^ here
codemessage
E2004Value is not callable

Offline

terminal
$ wowlua explain E2008
E2008 (error): Method called without self (use :)

source on GitHub ↗