E06330: argument types are not compatible with each other
What went wrong
The type arguments you're using with a generic type are incompatible with each other or with constraints defined on the generic type.
Worked examples
Compilable examples demonstrating this error and the correct fix:
- ek9 -q 885 (Why does EK9 report E06330 when using a function with the...)
How to fix it
- Check generic type definition for constraints
- Ensure your type implements required traits
- Add missing methods/operators to satisfy constraints
Common causes
- Type parameters violate constraints
- Types don't satisfy required relationships
- Conflicting type bounds
- Missing trait implementation on type argument
See also
Examples
Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.
Fails with E06330: argument types are not compatible with each other
#!ek9 defines module error.e06330.bad defines record R1 prop1 as String: String() prop2 as Date: Date() R1() -> p1 as String p2 as Date this.prop1 :=: p1 this.prop2 :=: p2 default operator defines function InvalidProp1ComparatorC() -> o1 as Date o2 as R1 <- rtn as Integer: 66 InvalidProp1ComparatorE() -> o1 as Duration o2 as Duration <- rtn as Integer: 1 defines function InvalidComparatorFunctionStreamCatSort3() stdout <- Stdout() records <- [R1("last", 2010-10-01), R1("last", 2010-10-02), R1("first", 2010-10-01)] cat records | sort with InvalidProp1ComparatorC > stdout InvalidComparatorFunctionStreamCatSort5() stdout <- Stdout() records <- [R1("last", 2010-10-01), R1("last", 2010-10-02), R1("first", 2010-10-01)] cat records | sort with InvalidProp1ComparatorE > stdout
Fixed: The comparator takes two of the item type and returns an Integer
#!ek9 defines module error.e06330.good defines record R1 prop1 as String: String() prop2 as Date: Date() R1() -> p1 as String p2 as Date this.prop1 :=: p1 this.prop2 :=: p2 default operator defines function Prop1R1Comparator() -> o1 as R1 o2 as R1 <- rtn as Integer: o1.prop1 <=> o2.prop1 ComparatorFunctionStreamCatSort4() stdout <- Stdout() records <- [R1("last", 2010-10-01), R1("last", 2010-10-02), R1("first", 2010-10-01)] cat records | sort with Prop1R1Comparator > stdout
Questions and answers
These Q&A entries show E06330 and its fix:
Found a problem?
If EK9 reported E06330 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.