v0.13.8
errors and warnings / classes

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

× failswowlua
abstract class Shape    abstract function area(): numberendprint(Shape.new())
✓ compileswowlua
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
codemessage
E3003Abstract method not implemented

Offline

terminal
$ wowlua explain E3002
E3002 (error): Cannot instantiate an abstract class

source on GitHub ↗