E07406: returning block is not required as there is no 'lhs' variable to assign it to
What went wrong
You've added a returning block (<- ...) to a control structure, but you're not using it in an assignment. The return value would be lost.
Worked examples
Compilable examples demonstrating this error and the correct fix:
- ek9 -q 782 (When does a switch need a returning block in EK9?)
How to fix it
- Capture the result in an assignment
- Or remove returning block for statement form
Common causes
- Statement with return that's not captured
- Refactoring left orphaned return
See also
Examples
Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.
Fails with E07406: returning block is not required as there is no 'lhs' variable to assign it to
#!ek9 defines module error.e07406.bad defines function describe() -> word as String <- rtn as String: String() //Nothing receives the switch's value switch word <- text as String: String() case "ToCheck" rtn: "Jackpot" default rtn: "Nothing"
Fixed: Remove the returning declaration from a switch statement
#!ek9 defines module error.e07406.good defines function describe() -> word as String <- rtn as String: String() //A switch statement: no returning variable switch word case "ToCheck" rtn: "Jackpot" default rtn: "Nothing"
Questions and answers
These Q&A entries show E07406 and its fix: