E06270: parameter mismatch

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

What went wrong

You're passing a function/delegate but its signature doesn't match what the receiving function expects - either parameter types or return type differ.

Worked examples

Compilable examples demonstrating this error and the correct fix:

  • ek9 -q 840 (Why does passing the wrong type to a function cause E06...)
  • ek9 -q 250 (Why is the compiler reporting a type mismatch?)
  • ek9 -q 656 (How does EK9 validate argument counts when calling generi...)
  • ek9 -q 258 (What is type coercion and promotion in method calls?)
  • ek9 -q 49 (How do I define a function in EK9?)

How to fix it

  1. Check expected function signature (parameter types AND return type)
  2. Ensure your function matches exactly
  3. Verify parameter count is correct

Common causes

  • Function signature mismatch
  • Wrong number of parameters in delegate
  • Wrong return type in delegate
  • Parameter types in wrong order

See also

  • E06270: function delegate type mismatch (this error)
  • E06260: a package property of the wrong shape (not a call)
  • E06280: too many arguments

https://ek9.io/functions.html https://ek9.io/forAI.json#$.methodResolution.functionResolution

Examples

Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.

Fails with E06270: parameter mismatch

#!ek9
defines module error.e06270.bad

  defines class

    Tally
      source as counter?

      default private Tally()

      Tally()
        -> callback as counter
        this.source: callback

      current()
        <- rtn as Integer?
        //The delegate takes no arguments
        rtn: source(21)

      default operator ?

  defines function

    counter() as abstract
      <- rtn as Integer?

Fixed: Call the delegate with the arguments its function type declares - here none

#!ek9
defines module error.e06270.good

  defines class

    Tally
      source as counter?

      default private Tally()

      Tally()
        -> callback as counter
        this.source: callback

      current()
        <- rtn as Integer: source()

      default operator ?

  defines function

    counter() as abstract
      <- rtn as Integer?

Questions and answers

These Q&A entries show E06270 and its fix: