E01083: multiple '<-' arrows not supported - only one return declaration allowed
What went wrong
EK9 functions and methods have exactly ONE return declaration using '<-'. Multiple '<-' arrows are not allowed - use a record to return multiple values.
Worked examples
Compilable examples demonstrating this error and the correct fix:
- ek9 -q 917 (How do return values work in EK9 functions?)
How to fix it
- Remove additional '<-' arrows
- For multiple return values, create a record type
- Return a single instance of that record
The [EXAMPLE] section below shows the second '<-' rejected, and the two values returned as one record.
Design rationale
A single return declaration:
- Makes function contracts explicit and clear
- Enables powerful type inference
- Simplifies control flow analysis
- Prevents the "out parameter" anti-pattern
Records provide named, typed multiple return values that are self-documenting and type-safe.
See also
- E01082: Multiple '->' arrows (parameters)
- https://ek9.io/functions.html
- https://ek9.io/records.html
Examples
Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.
Fails with E01083: multiple '<-' arrows not supported - only one return declaration allowed
#!ek9 defines module error.e01083.bad defines function measure() -> input as String <- text as String: input <- count as Integer: length input
Fixed: A function has one returning variable: remove the second arrow
#!ek9 defines module error.e01083.good.fix defines function measure() -> input as String <- text as String: input
Fixed: Return one value: a record that holds both
#!ek9 defines module error.e01083.good defines record Measurement text as String? count as Integer? default private Measurement() Measurement() -> text as String count as Integer this.text: text this.count: count default operator ? defines function measure() -> input as String <- rtn as Measurement: Measurement(input, length input)
Questions and answers
These Q&A entries show E01083 and its fix:
Found a problem?
If EK9 reported E01083 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.