E07550: must return an Integer

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

What went wrong

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

Worked examples

Compilable examples demonstrating this error and the correct fix:

  • ek9 -q 779 (Why must certain operators return a value in EK9?)
  • ek9 -q 239 (How do comparison and ordering operators work in EK9?)
  • ek9 -q 238 (What operators does EK9 support and why is the set fixed?)
  • ek9 -q 242 (How do conversion and introspection operators work in EK9?)
  • ek9 -q 245 (How do I implement all the operators my custom type needs?)

How to fix it

  1. Change return type to Integer

Common causes

  • Comparison operator (<=>) returning wrong type
  • Counter/index function type mismatch

See also

  • E07550: Integer return required (this error)
  • E07520: Boolean return required
  • E07570: String return required

Examples

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

Fails with E07550: must return an Integer

#!ek9
defines module error.e07550.bad

  defines class

    Score
      points as Integer: 0

      //'<=>' answers less, equal or greater as an Integer
      operator <=> as pure
        -> other as Score
        <- rtn as Score: this

      default operator ?

      operator #? as pure
        <- rtn as Integer: #?points

Fixed: '<=>' returns an Integer: less, equal or greater

#!ek9
defines module error.e07550.good.fix

  defines class

    Score
      points as Integer: 0

      //'<=>' answers less, equal or greater as an Integer
      operator <=> as pure
        -> other as Score
        <- rtn as Integer: points <=> other.points

      default operator ?

      operator #? as pure
        <- rtn as Integer: #?points

Fixed: Return an Integer

#!ek9
defines module error.e07550.good

  defines class

    Score
      points as Integer?

      default private Score()

      Score()
        -> initial as Integer
        this.points: initial

      total() as pure
        <- rtn as Integer: points

      //Negative, zero or positive
      operator <=> as pure
        -> other as Score
        <- rtn as Integer: points <=> other.total()

      operator #? as pure
        <- rtn as Integer: #?points

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

Questions and answers

These Q&A entries show E07550 and its fix:

Found a problem?

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