E07520: must return a Boolean

Category: E07xxx Full resolution · Reported in phase: EXPLICIT_TYPE_SYMBOL_DEFINITION · Classification: MUST_RETURN_BOOLEAN · All error codes

What went wrong

A function or method is required to return Boolean but returns a different type.

Worked examples

Compilable examples demonstrating this error and the correct fix:

  • ek9 -q 24 (How do I convert between types?)
  • ek9 -q 25 (What is the promote operator?)
  • ek9 -q 22 (How do I declare a variable in EK9?)
  • ek9 -q 5 (How are EK9 source files structured?)
  • ek9 -q 16 (How does indentation work in EK9?)

How to fix it

  1. Ensure return type is Boolean

Common causes

  • Predicate function with wrong return
  • Condition implementation error

See also

  • E07520: Boolean return required (this error)
  • E07530: Boolean type required in context

Examples

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

Fails with E07520: must return a Boolean

#!ek9
defines module error.e07520.bad

  defines class

    Reading
      celsius <- 0.0

      //'?' answers yes or no
      override operator ? as pure
        <- rtn as Integer: 1

Fixed: Return a Boolean

#!ek9
defines module error.e07520.good

  defines class

    Reading
      celsius <- 0.0

      override operator ? as pure
        <- rtn as Boolean: celsius?

Questions and answers

These Q&A entries show E07520 and its fix:

Found a problem?

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