E06240: either all variable must be named or none, when passing parameters
What went wrong
When using named parameters, you must be consistent - either ALL parameters are named, or NONE are named. Mixing named and positional causes ambiguity.
Worked examples
Compilable examples demonstrating this error and the correct fix:
- ek9 -q 115 (How do dynamic classes work in EK9?)
How to fix it
- Either add names to ALL parameters
- Or remove names from ALL parameters
- Check for partially converted code
Rationale
Named parameters are matched by name, positional by position. Mixing creates ambiguous binding - should second arg match by position or skip to named?
Common causes
- Partially converting to named parameters
- Accidentally adding name to one parameter
- Copy/paste from different calling style
See also
Examples
Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.
Fails with E06240: either all variable must be named or none, when passing parameters
#!ek9 defines module error.e06240.bad defines trait RangeCheck within() -> text as String <- result as Boolean? defines program MixedCaptures() max <- 100 //One capture named, one not check <- (min: 10, max) with trait of RangeCheck as class override within() -> text as String <- result as Boolean: length text > min and length text < max default operator ? require check?
Fixed: Name every captured variable, or none
#!ek9 defines module error.e06240.good.fix defines trait RangeCheck within() -> text as String <- result as Boolean? defines program MixedCaptures() max <- 100 //One capture named, one not check <- (min: 10, max: max) with trait of RangeCheck as class override within() -> text as String <- result as Boolean: length text > min and length text < max default operator ? require check?
Fixed: Name every capture, or none
#!ek9 defines module error.e06240.good defines trait RangeCheck within() -> text as String <- result as Boolean? defines program AllNamed() stdout <- Stdout() max <- 100 check <- (min: 10, max: max) with trait of RangeCheck as class override within() -> text as String <- result as Boolean: length text > min and length text < max default operator ? stdout.println($check.within("short"))
Fixed: Or capture plain variables only, all unnamed
#!ek9 defines module error.e06240.good.positional defines trait RangeCheck within() -> text as String <- result as Boolean? defines program AllPositional() stdout <- Stdout() min <- 10 max <- 100 check <- (min, max) with trait of RangeCheck as class override within() -> text as String <- result as Boolean: length text > min and length text < max default operator ? stdout.println($check.within("short"))
Questions and answers
These Q&A entries show E06240 and its fix:
Found a problem?
If EK9 reported E06240 for a program you think is valid, or did not report it where it should have, use the compiler form with the smallest program that shows it. If this page is wrong or unclear, use the documentation form. Both are at github.com/ek9lang/ek9-issues.