Why does EK9 reject a named argument whose name does not match the parameter?
← Functions and Methods · Ref: Q1343
EK9 lets you pass arguments by name using 'name: value' syntax, which makes call sites self-documenting. When you do, every name must EXACTLY match a declared parameter name (case-sensitive) and stay in declaration order. Passing a name that does not exist on the signature - a typo, a guessed name, or a name left stale after a refactor - raises E06250.
The fix is to read the function or method signature and use the real parameter names. In the example, makeRange declares 'low' and 'high'; calling makeRange(low: 2, high: 10) compiles, while makeRange(low: 2, max: 10) fails because there is no parameter called 'max'.
See Q597 for function parameters. See Q942 for passing functions as parameters.
Example
defines module qa.functionsAndMethods.namedarguments defines function //Two parameters with clear, documented names. makeRange() as pure -> low as Integer high as Integer <- rtn as Integer: high - low defines program NamedArgumentDemo() stdout <- Stdout() //CORRECT: named arguments match the declared parameter names exactly, //in declaration order. Self-documenting and compile-checked. span <- makeRange(low: 2, high: 10) stdout.println(`Span via named args: ${span}`) //Positional calls remain valid too when names are obvious. other <- makeRange(0, 5) stdout.println(`Span via positional args: ${other}`)
Common mistakes
E06250 — makeRange declares parameters 'low' and 'high', but the call uses 'max' as the second name. Named arguments must match the declared parameter names exactly and stay in declaration order, so the unknown name 'max' raises E06250. Use the real parameter name 'high'. See ek9 -h E06250 for details.
Incorrect:
span <- makeRange(low: 2, max: 10)
Correct:
span <- makeRange(low: 2, high: 10)
Other ways to ask this
- What triggers E06250 when calling a function with named parameters?
- Why must named call arguments use the exact declared parameter names in EK9?
- How do I fix 'the order and naming of arguments must match parameters'?
Coming from another language?
Python: keyword arguments are checked at runtime - a wrong keyword raises TypeError only when the call executes. Kotlin/C#: named arguments are compile-checked like EK9, a wrong name fails to compile. Java: has no named arguments at all, so the whole class of name-mismatch bugs is replaced by silent positional mistakes. EK9: named arguments are compile-time validated (E06250) and must match the declared names exactly and stay in order.
Keywords: function, call, E06250, signature, order, named, parameter, argument, match