E07550: must return an Integer
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
- Change return type to Integer
Common causes
- Comparison operator (<=>) returning wrong type
- Counter/index function type mismatch
See also
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:
- Q238: What operators does EK9 support and why is the set fixed?
- Q239: How do comparison and ordering operators work in EK9?
- Q242: How do conversion and introspection operators work in EK9?
- Q245: How do I implement all the operators my custom type needs?
- Q779: Why must certain operators return a value in EK9?
- Q911: What does the #? operator mean in EK9?
- Q1053: Implement #? manually on a class that combines multiple fields.
- Q1229: Select the higher-priority Task from two optional task records.