E06320: invalid number of parameters

Category: E06xxx Type hierarchy checks · Reported in phase: FULL_RESOLUTION · Classification: INVALID_NUMBER_OF_PARAMETERS · All error codes

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:

How to fix it

  1. Give the dispatcher entry point one parameter (or two for a pair dispatch)
  2. Give each handler the same number of parameters as the entry point
  3. 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

  • E06320: wrong parameter COUNT on a dispatcher or its handler (this error)
  • E06270: wrong parameter TYPE in a call

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: