E01087: empty defines block - add at least one type, function, or program definition

Category: E01xxx Parsing and excluded constructs · Reported in phase: SYMBOL_DEFINITION · Classification: EMPTY_DEFINES_BLOCK · All error codes

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

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: 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: