errors and warnings / classes / E3001
E3001 error
super(...) missing, repeated, or after use of self
- area
- classes (x3xxx)
- fails the build
- yes
A derived class's constructor calls super(...) wrongly. It must call it
exactly once, as a statement at the top level of the constructor body, before
anything uses self, the arguments of super(...) included: until then the
instance isn't built (for a widget class, the frame doesn't exist yet). The
code is also reported when a class without a superclass calls super(...),
and when a derived class's constructor doesn't call it at all.
Example
class Animal name: string constructor(name: string) self.name = name endendclass Dog extends Animal constructor(name: string) self.name = name super(name) endendprint(Dog.new("Rex"))class Animal name: string constructor(name: string) self.name = name endendclass Dog extends Animal tricks: number = 0 constructor(name: string) super(name) self.tricks = 1 endendprint(Dog.new("Rex"))The compiler reports it like this:
error[E3001]: `self` is used before `super(...)` ┌─ src/main.wowlua:9:9 │ 9 │ self.name = name │ ^^^^ used here
Related codes
| code | message |
|---|---|
| E3040 | Local or parameter named super inside a class body |
Offline
$ wowlua explain E3001 E3001 (error): super(...) missing, repeated, or after use of self