E01087: empty defines block - add at least one type, function, or program definition
What went wrong
A 'defines' block (class, function, trait, etc.) is empty with no declarations inside it. Every 'defines' block must contain at least one declaration. An empty block serves no purpose and is likely a copy-paste error or incomplete code.
Worked examples
Compilable examples demonstrating this error and the correct fix:
- ek9 -q 943 (Why does EK9 reject empty defines blocks?)
Common causes
- Scaffolding code that was never filled in
- Copy-paste of a 'defines' block without adding any declarations
- Accidentally deleting all declarations from a block
- Comments-only block (comments are hidden from the parser)
How to fix it
Either add at least one declaration inside the block, or remove the empty block entirely.
The [EXAMPLE] section below shows empty blocks rejected, and the same module with each block declaring a construct.
See also
- E01086: Method or field placed after operator declarations
- https://ek9.io/structure.html
Examples
Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.
Fails with E01087: empty defines block - add at least one type, function, or program definition
#!ek9 defines module error.e01087.bad defines class defines function defines trait
Fixed: An empty defines block says nothing: give it a member, or take it out
#!ek9 defines module error.e01087.good.fix defines function hello() <- rtn as String: "hello"
Fixed: Every defines block declares at least one construct; leave out the ones you do not need
#!ek9 defines module error.e01087.good defines class Counter count as Integer: 0 increment() count++ default operator ? defines function startingCount() <- rtn as Integer: 0
Questions and answers
These Q&A entries show E01087 and its fix:
Found a problem?
If EK9 reported E01087 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.