errors and warnings / classes / E3002
E3002 error
Cannot instantiate an abstract class
- area
- classes (x3xxx)
- fails the build
- yes
An abstract class is instantiated, directly or through a ClassOf<T> whose
T is abstract. An abstract class only exists to be extended: its abstract
methods have no body. Create an instance of a concrete subclass instead.
Example
abstract class Shape abstract function area(): numberendprint(Shape.new())abstract class Shape abstract function area(): numberendclass Square extends Shape side: number = 2 override function area(): number return self.side * self.side endendprint(Square.new():area())The compiler reports it like this:
error[E3002]: cannot instantiate the abstract class `Shape` ┌─ src/main.wowlua:4:7 │ 4 │ print(Shape.new()) │ ^^^^^^^^^ here
Related codes
| code | message |
|---|---|
| E3003 | Abstract method not implemented |
Offline
$ wowlua explain E3002 E3002 (error): Cannot instantiate an abstract class