E06320: invalid number of parameters
What went wrong
A DISPATCHER has the wrong number of parameters. A dispatcher entry point ('as dispatcher') routes on the type of its argument, so it takes one parameter, or two when it dispatches on a pair of types. Every handler of the same name must take the same number of parameters as the entry point it serves.
Worked examples
Compilable examples demonstrating this error and the correct fix:
- ek9 -q 1344 (Why does EK9 report E06320 when a dispatcher handler h...)
How to fix it
- Give the dispatcher entry point one parameter (or two for a pair dispatch)
- Give each handler the same number of parameters as the entry point
- If a handler needs different input, give it a different name
Common causes
- Declaring 'as dispatcher' on a method with no parameters
- A handler overload with one parameter beside a two-parameter entry point
- A dispatcher with three or more parameters
See also
Examples
Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.
Fails with E06320: invalid number of parameters
#!ek9 defines module error.e06320.bad defines class Processor //A dispatcher routes on its parameter: it needs one or two process() as dispatcher <- rtn as String: "nothing" process() -> input as Integer <- rtn as String: $input
Fixed: Give the dispatcher entry point the parameter it routes on
#!ek9 defines module error.e06320.good defines class Processor process() as dispatcher -> input as Any <- rtn as String: "something" process() -> input as Integer <- rtn as String: $input process() -> input as String <- rtn as String: input
Questions and answers
These Q&A entries show E06320 and its fix: