E08091: parameter is declared but never used in the function/method body
What went wrong
A parameter is declared in a function or method signature but is never referenced in the body. Unused parameters add noise to APIs and may indicate incomplete implementation or a copy/paste error.
Worked examples
Compilable examples demonstrating this error and the correct fix:
- ek9 -q 307 (How do I verify that code does not throw an exception in ...)
- ek9 -q 206 (How do I measure test coverage in EK9?)
- ek9 -q 209 (How do I test that code throws or does not throw exceptio...)
How to fix it
- Use the parameter in the function body as intended
- Remove the parameter if it is truly unnecessary
- If the parameter is required by an interface or override, use it or reconsider the design
Common causes
- Incomplete implementation (parameter added but logic not yet written)
- Copy/paste from another function with different parameter needs
- Refactoring that removed usage but not the parameter declaration
See also
Examples
Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.
Fails with E08091: parameter is declared but never used in the function/method body
#!ek9 defines module error.e08091.bad defines function unusedSingleParam() -> ignored as String <- result as String: "done" unusedOneOfTwo() -> used as String notUsed as Integer <- result as String: used describeReady() <- rtn as String: unusedOneOfTwo("ready", 3) usedParam() -> input as String <- result as String: input abstractBase() as abstract -> input as String <- result as String?
Fixed: Remove the parameter, or use it
#!ek9 defines module error.e08091.good defines function singleResult() <- result as String: "done" bothUsed() -> used as String count as Integer <- result as String: used + $count
Questions and answers
These Q&A entries show E08091 and its fix: