E50080: cannot make a call on an abstract function/type directly
What went wrong
You're trying to directly instantiate an abstract type or function. Abstract types define contracts without implementation - you must extend them.
Worked examples
Compilable examples demonstrating this error and the correct fix:
- ek9 -q 821 (Why can't I construct an abstract type directly in EK9?)
- ek9 -q 831 (Why can't I use an abstract function as a return type dir...)
- ek9 -q 103 (What are abstract classes and methods in EK9?)
- ek9 -q 111 (What are components in EK9?)
- ek9 -q 114 (How do aspects work with components for AOP?)
[BUILT-IN ABSTRACT TYPES]
- SignalHandler: `-> signal as String <- result as Integer?`
- TCPHandler: `-> input as StringInput, output as StringOutput`
How to fix it
- Create concrete implementation extending abstract type
- Use built-in concrete subtypes where available
- Use dynamic function syntax: `() is AbstractType as function`
Common causes
- Direct call to abstract function
- Constructor call on abstract class
- Trying to instantiate built-in abstract types
See also
Examples
Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.
Fails with E50080: cannot make a call on an abstract function/type directly
#!ek9 defines module error.e50080.bad defines class Shape as abstract area() as abstract <- rtn as Float? defines function demo() <- rtn as Float? shape <- Shape() rtn: shape.area()
Fixed: An abstract type is never constructed: take a Shape as a parameter and let the caller supply a concrete one
#!ek9 defines module error.e50080.good.fix defines class Shape as abstract area() as abstract <- rtn as Float? defines function demo() -> shape as Shape <- rtn as Float? rtn: shape.area()
Fixed: Construct a concrete subtype
#!ek9 defines module error.e50080.good defines class Shape as abstract area() as abstract <- rtn as Float? Circle extends Shape radius as Float: 5.0 override area() <- rtn as Float: radius * radius default operator ? defines function demo() <- rtn as Float? shape as Shape: Circle() rtn: shape.area()
Questions and answers
These Q&A entries show E50080 and its fix:
Found a problem?
If EK9 reported E50080 for a program you think is valid, or did not report it where it should have, use the compiler form with the smallest program that shows it. If this page is wrong or unclear, use the documentation form. Both are at github.com/ek9lang/ek9-issues.