E10010: 'void' return type cannot be used with an assignment
What went wrong
You're trying to use a VOID function's result in an assignment or expression. Void functions don't return values.
Worked examples
Compilable examples demonstrating this error and the correct fix:
- ek9 -q 941 (Why can't I assign the result of a void function in E...)
How to fix it
- Add return value to function if needed
- Or don't try to capture void result
The [EXAMPLE] section below shows a void function's result held in a variable, and the call made on its own beside a function that does return a value.
Common causes
- Assigning result of procedure-like function
- Using void function in expression
See also
Examples
Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.
Fails with E10010: 'void' return type cannot be used with an assignment
#!ek9 defines module error.e10010.bad defines function logItem() -> item as String stdout <- Stdout() stdout.println(item) process() outcome <- logItem("first") require outcome?
Fixed: Call it as a statement, or give it a returning variable
#!ek9 defines module error.e10010.good defines function logItem() -> item as String stdout <- Stdout() stdout.println(item) describe() -> item as String <- rtn as String: `item: ${item}` process() logItem("first") outcome <- describe("second") logItem(outcome)
Questions and answers
These Q&A entries show E10010 and its fix:
Found a problem?
If EK9 reported E10010 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.