E06270: parameter mismatch
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
- Check expected function signature (parameter types AND return type)
- Ensure your function matches exactly
- 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:
- Q49: How do I define a function in EK9?
- Q250: Why is the compiler reporting a type mismatch?
- Q258: What is type coercion and promotion in method calls?
- Q656: How does EK9 validate argument counts when calling generic functions?
- Q745: How does EK9 validate function and method parameters?
- Q781: Why does EK9 reject calls with the wrong number of arguments?
- Q840: Why does passing the wrong type to a function cause E06270 in EK9?
- Q942: How do I pass a function as a parameter in EK9?
- Q951: What happens when you pass the wrong kind of construct as a parameter?
- Q1388: How do I generate a secure random token, nonce or salt in EK9?