E05100: cannot override anything
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
- Remove 'override' from the program or service method (and 'abstract', which E50040 reports for the same reason).
- 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
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:
Found a problem?
If EK9 reported E05100 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.