TP0234
Error: abstract class instantiated (M28)
Messages
Section titled “Messages”cannot instantiate abstract class '<C>', with helpit does not implement '<B>.<m>'('<B>.<m>' and '<B>.<n>'for more)'cls(…)' may construct the abstract class '<C>''<C>' cannot add abstract method '<m>', since '<B>.<cm>' calls 'cls(…)'(M28)
Example
Section titled “Example”From the golden case tests/cases/m28/tp0234_abstract.tpn:
# Abstract classes can't be instantiated (SPEC §4.8).class Shape(ABC): @abstractmethod def area(self) -> float: ...
@abstractmethod def perimeter(self) -> float: ...
@classmethod def unit(cls) -> Shape: return cls()
class Square(Shape): @override def area(self) -> float: return 1.0
class Full(Square): @override def perimeter(self) -> float: return 4.0
let a = Shape()let b = Square()let c = Full()
class Maker(ABC): def __init__(self): pass
@classmethod def make(cls) -> Maker: return cls()
class Late(Maker): @abstractmethod def run(self) -> int: ...The compiler reports:
tp0234_abstract.tpn:11:16: error TP0234: 'cls(…)' may construct the abstract class 'Shape'tp0234_abstract.tpn:23:9: error TP0234: cannot instantiate abstract class 'Shape' help: it does not implement 'Shape.area' and 'Shape.perimeter'tp0234_abstract.tpn:24:9: error TP0234: cannot instantiate abstract class 'Square' help: it does not implement 'Shape.perimeter'tp0234_abstract.tpn:37:9: error TP0234: 'Late' cannot add abstract method 'run', since 'Maker.make' calls 'cls(…)'The specification lists every code.
© 2026 Discover Edge, LLC · Taipan is released under the MIT License.