E06330: argument types are not compatible with each other

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

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:

How to fix it

  1. Check generic type definition for constraints
  2. Ensure your type implements required traits
  3. 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

  • E06330: type arguments incompatible with constraints (this error)
  • E06130: constrained type missing required constructors
  • E06190: Result same types for success/error

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.