E07430: return not required/supported in this context
What went wrong
A value is returned where nothing may be. Two declarations carry no return: a constructor, which makes the object and gives nothing back, and an operator that changes the object in place (':=:', ':^:', ':~:', '+=', '-=', '++', '--') which also returns nothing.
Worked examples
Compilable examples demonstrating this error and the correct fix:
- ek9 -q 118 (How do I implement the builder pattern in EK9?)
How to fix it
- Remove the returning declaration ('<- rtn as ...') from the constructor or in-place operator
- If a result is needed, use a method that returns it, or an operator that is meant to return one
Common causes
- Adding '<- rtn as ...' to a constructor
- Declaring ':=:' or '+=' as if it produced a new value
- Copying a method signature into an operator
See also
Examples
Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.
Fails with E07430: return not required/supported in this context
#!ek9 defines module error.e07430.bad defines class Wallet amount <- 0.0 holding() as pure <- rtn as Float: amount //Copy changes this object in place; it returns nothing default operator ? operator :=: -> other as Wallet <- rtn as Float: other.holding()
Fixed: Remove the returning declaration
#!ek9 defines module error.e07430.good defines class Wallet amount <- 0.0 holding() as pure <- rtn as Float: amount default operator ? operator :=: -> other as Wallet amount :=: other.holding()
Questions and answers
These Q&A entries show E07430 and its fix:
Found a problem?
If EK9 reported E07430 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.