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
class Counter n: number = 0 function bump() self.n += 1 endendlocal c = Counter.new()c.bump()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
Related codes
| code | message |
|---|---|
| E2004 | Value is not callable |
Offline
$ wowlua explain E2008 E2008 (error): Method called without self (use :)