E07740: implementation not provided, but services cannot be abstract
What went wrong
A service method doesn't have an implementation body. Unlike abstract classes, services must always provide implementations.
Worked examples
Compilable examples demonstrating this error and the correct fix:
- ek9 -q 1326 (Why does EK9 reject a service method that declares a r...)
Rationale
Services are CONCRETE - all methods must be implemented. There are no abstract service methods.
How to fix it
- Provide implementation body for the service method
The [EXAMPLE] section below shows a GET method with no body, and the same method giving its response a value.
Common causes
- Forgot to add implementation
- Thinking services support abstract methods
See also
Examples
Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.
Fails with E07740: implementation not provided, but services cannot be abstract
#!ek9 defines module error.e07740.bad defines class TextResponse with trait of HTTPResponse text as String? default private TextResponse() TextResponse() -> body as String this.text: body override contentType() as pure <- rtn as String: "text/plain" override content() <- rtn as Bytes: Bytes().withUtf8(text) override status() as pure <- rtn as Integer: 200 default operator ? defines service Addresses for :/addresses open //A service is never abstract: every method has a body byId() as GET for :/{id} -> id as String <- response as HTTPResponse?
Fixed: Give the service method a body
#!ek9 defines module error.e07740.good defines class TextResponse with trait of HTTPResponse text as String? default private TextResponse() TextResponse() -> body as String this.text: body override contentType() as pure <- rtn as String: "text/plain" override content() <- rtn as Bytes: Bytes().withUtf8(text) override status() as pure <- rtn as Integer: 200 default operator ? defines service Addresses for :/addresses open byId() as GET for :/{id} -> id as String <- response as HTTPResponse: TextResponse(`address ${id}`)
Questions and answers
These Q&A entries show E07740 and its fix:
Found a problem?
If EK9 reported E07740 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.