E10011: 'Void' is the absence of a value - it cannot be the type of a variable, property, parameter or type argument
What went wrong
'Void' was used as the type of something that holds a value: a variable, a property, a parameter, a returning variable, or a type argument such as 'List of Void' or 'Dict of (String, Void)'.
'Void' is not a value. It is what a function or method returns when it has no returning variable ('<-' line). Nothing can hold a 'Void', so a 'Void' parameter could never be passed anything and a 'List of Void' could never contain anything.
Worked examples
Compilable examples demonstrating this error and the correct fix:
- ek9 -q 256 (What is the Void type in EK9?)
How to fix it
- If the parameter, property or variable carries no information, remove it
- Otherwise give it the type of the value it should hold
- To make a function return nothing, omit its returning variable entirely - never declare one typed Void
The [EXAMPLE] section below shows Void as a parameter, a property, a local, a returning variable and a type argument, then a function with no parameter and no returning variable, and a List of the type really needed.
Common causes
- Translating Java's 'Void' type argument (e.g. 'Callable<Void>') literally
- Writing 'Void' as an explicit return type instead of omitting the '<-' line
- A placeholder parameter added to match another function's signature
See also
Examples
Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.
Fails with E10011: 'Void' is the absence of a value - it cannot be the type of a variable, property, parameter or type argument
#!ek9 defines module error.e10011.bad defines record Holder nothing as Void? default operator ? defines trait Processor process() as abstract -> nothing as Void defines class Worker work() -> nothing as Void doNothing() defines function //VALID: no returning variable - this function returns Void doNothing() stdout <- Stdout() stdout.println("nothing") voidParameter() -> nothing as Void stdout <- Stdout() stdout.println("void parameter") voidReturningVariable() as abstract <- nothing as Void? voidLocalVariable() nothing as Void? stdout <- Stdout() stdout.println(`${nothing?}`) voidListParameter() -> nothings as List of Void stdout <- Stdout() stdout.println("void list parameter") voidNestedListParameter() -> nothings as List of List of Void stdout <- Stdout() stdout.println("void nested list parameter") voidListConstruction() nothings <- List() of Void stdout <- Stdout() stdout.println($length nothings) voidDictConstruction() nothings <- Dict() of (String, Void) stdout <- Stdout() stdout.println($length nothings) voidOptionalReturn() as abstract <- nothing as Optional of Void?
Fixed: Leave out what has no value: a function with no returning variable already returns nothing
#!ek9 defines module error.e10011.good defines function doNothing() stdout <- Stdout() stdout.println("nothing") messages() <- rtn as List of String: List()
Found a problem?
If EK9 reported E10011 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.