E50070: cannot use an abstract function in this manner

Category: E50xxx Common errors · Reported in phase: FULL_RESOLUTION · Classification: BAD_ABSTRACT_FUNCTION_USE · All error codes

What went wrong

You're using an abstract function in a context that requires a concrete implementation. Abstract functions define signatures only.

Worked examples

Compilable examples demonstrating this error and the correct fix:

  • ek9 -q 848 (Can I assign an abstract function as a delegate in EK9?)

How to fix it

  1. Create concrete implementation that extends abstract function
  2. Use concrete subfunction instead of abstract base
  3. Implement the abstract function body

Common causes

  • Trying to call abstract function directly
  • Using abstract function where concrete needed
  • Missing implementation of abstract function

See also

  • E50070: abstract function in concrete context (this error)
  • E50080: abstract type instantiation

Examples

Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.

Fails with E50070: cannot use an abstract function in this manner

#!ek9
defines module error.e50070.bad

  defines function

    Processor() as abstract
      -> input as String
      <- output as String?

    demo()
      <- rtn as String?
      processor as Processor: Processor
      rtn: processor("test")

Fixed: Use a concrete function that is a Processor

#!ek9
defines module error.e50070.good

  defines function

    Processor() as abstract
      -> input as String
      <- output as String?

    UpperCaseProcessor() is Processor
      -> input as String
      <- output as String: input.upperCase()

    demo()
      <- rtn as String?
      processor as Processor: UpperCaseProcessor
      rtn: processor("test")

Questions and answers

These Q&A entries show E50070 and its fix: