E07200: 'default' of operators requires property/field to have appropriate operator

Category: E07xxx Full resolution · Reported in phase: FULL_RESOLUTION · Classification: MISSING_OPERATOR_IN_PROPERTY_TYPE · All error codes

What went wrong

You're using 'default operator' but one of your PROPERTY TYPES doesn't have the required operator. Default operators call operators on each property.

An EXPLICIT 'default operator <=>' (or '<', '<=', '>', '>=') needs every property's '<=>' to order every two SET values. Money orders only within one currency and Dimension only within one unit suffix (it is unset between them), so a generated '<=>' over either would not: write '<=>' by hand over the currency ('#>') and then the amount ('#<') (E07188 explains the rule). The BARE 'default operator' is not an error: it gives the type '==' and withdraws the ordering, so a use of it is E07620.

Worked examples

Compilable examples demonstrating this error and the correct fix:

  • ek9 -q 1315 (Why does 'default operator' fail when a property's typ...)

[BUILT-IN TYPES WITH OPERATORS] Integer, Float, String, Boolean, Date, Time, DateTime, Duration, Money

Types that may lack operators

  • Custom classes/records without 'default operator'
  • Abstract types
  • Types from external modules

How to fix it

  1. Add default operators to property's type
  2. Or implement operators manually

The [EXAMPLE] section below shows a generated '$' over a property whose type has none, and the fix: give the property's type the operator too.

See also

  • E07200: property type missing operator (this error)
  • E07188: a '<=>' must order every two set values (Money and Dimension are partial)
  • E07190: super class missing operator

Examples

Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.

Fails with E07200: 'default' of operators requires property/field to have appropriate operator

#!ek9
defines module error.e07200.bad

  defines class

    Sensor
      reading <- Time()

      default operator ?

    Station
      sensor <- Sensor()

      //Sensor has no '$', so a generated '$' cannot convert the sensor field
      default operator ?

      default operator $

Fixed: Give the property type the operator

#!ek9
defines module error.e07200.good

  defines class

    Sensor
      reading <- Time()

      default operator ?
      default operator $

    Station
      sensor <- Sensor()

      //Sensor now has '$', so this can be generated
      default operator ?

      default operator $

Questions and answers

These Q&A entries show E07200 and its fix: