E05100: cannot override anything

Category: E05xxx Explicit type symbol definition · Reported in phase: SYMBOL_DEFINITION · Classification: OVERRIDE_INAPPROPRIATE · All error codes

What went wrong

You have put 'override' on a method of a construct that can never be extended - a program, or a service's methods/operations. Nothing can inherit from these, so there is no parent to override; the keyword is meaningless here and is rejected. ('abstract' on the same methods is the separate error E50040 - same reason, no subclass could ever implement it.)

This is NOT the "no matching parent method" case - that is E05110. E05100 is about the KIND of construct, not the method's signature.

Worked examples

Compilable examples demonstrating this error and the correct fix:

  • ek9 -q 826 (Why does EK9 reject override on constructs that cannot ov...)

How to fix it

  1. Remove 'override' from the program or service method (and 'abstract', which E50040 reports for the same reason).
  2. If you genuinely need polymorphism, move the behaviour into a class or trait (which can be extended) and have the program/service delegate to it.

Rationale

Programs and services are entry points, not types in a hierarchy: a program is the method the runtime invokes, a service's operations are HTTP routes. Allowing 'override'/'abstract' on them would advertise an extension point that cannot exist. The grammar is shared with classes for simplicity, so this rule closes the gap it leaves.

Common causes

  • Copying a method from a class into a program or service, keyword included
  • Assuming a service can extend another service
  • Marking a service operation 'abstract' meaning "to be implemented later"

See also

  • E05100: 'override' on a non-extendable construct (this error)
  • E50040: 'abstract' on a program or service method (or any construct that cannot be abstract)
  • E05110: 'override' declared but NO parent/trait method matches it
  • E05120: parent method matches but 'override' is MISSING

Examples

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

Fails with E05100: cannot override anything

#!ek9
defines module error.e05100.bad

  defines service

    Addresses for :/addresses open

      //A service extends nothing either
      override describe()
        <- rtn as String: "addresses"

  defines program

    //A program extends nothing, so there is nothing to override
    override Report()
      stdout <- Stdout()
      stdout.println("report")

Fixed: Remove 'override' where there is nothing to extend

#!ek9
defines module error.e05100.good

  defines service

    Addresses for :/addresses open

      describe()
        <- rtn as String: "addresses"

  defines program

    Report()
      stdout <- Stdout()
      stdout.println("report")

Questions and answers

These Q&A entries show E05100 and its fix: