E07860: require a function or function delegate

Category: E07xxx Full resolution · Reported in phase: FULL_RESOLUTION · Classification: FUNCTION_OR_DELEGATE_REQUIRED · All error codes

What went wrong

This context requires a function or function delegate but one wasn't provided.

Worked examples

Compilable examples demonstrating this error and the correct fix:

  • ek9 -q 857 (Why does stream split require a function or delegate?)

How to fix it

  1. Provide function or delegate
  2. Or use named function reference

Common causes

  • Missing function argument
  • Wrong type passed (value instead of function)

See also

  • E07860: function delegate required (this error)
  • E07870: Integer or function required

Examples

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

Fails with E07860: require a function or function delegate

#!ek9
defines module error.e07860.bad

  defines function

    doubleAll()
      <- rtn as List of Integer: List()
      doubler <- 42

      //map needs a function to apply to each item
      cat [1, 2, 3] | map with doubler > rtn

Fixed: Give map a function

#!ek9
defines module error.e07860.good

  defines function

    doubler()
      -> number as Integer
      <- rtn as Integer: number * 2

    doubleAll()
      <- rtn as List of Integer: List()
      cat [1, 2, 3] | map with doubler > rtn

Questions and answers

These Q&A entries show E07860 and its fix:

Found a problem?

If EK9 reported E07860 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.