E07230: 'default' with an operator must not have signature or body

Category: E07xxx Full resolution · Reported in phase: SYMBOL_DEFINITION · Classification: DEFAULT_WITH_OPERATOR_SIGNATURE · All error codes

What went wrong

You've added parameters or implementation to a 'default' operator. Default operators are AUTO-GENERATED - you can't customize them.

Worked examples

Compilable examples demonstrating this error and the correct fix:

  • ek9 -q 835 (Why can't I provide a signature or body when using 'defau...)

Rationale

'default' means "generate it for me" - you don't get to customize it.

How to fix it

  1. Remove parameters and body from default operator
  2. Or remove 'default' and provide full implementation

Common causes

  • Trying to customize default operator behavior
  • Copy/paste from regular operator

See also

  • E07230: default operator with params/body (this error)
  • E07220: unsupported default operator

Examples

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

Fails with E07230: 'default' with an operator must not have signature or body

#!ek9
defines module error.e07230.bad

  defines record
    Label
      text <- String()

      //'default' generates the whole operator: no signature, no body
      default operator ?

      default operator $ as pure
        <- rtn as String: text

Fixed: A default operator is just the word default and the operator: no signature, no body

#!ek9
defines module error.e07230.good.fix

  defines record
    Label
      text <- String()

      //'default' generates the whole operator: no signature, no body
      default operator ?

      default operator $

Fixed: Either 'default operator $' alone, or the operator written without 'default'

#!ek9
defines module error.e07230.good

  defines record
    Label
      text <- String()

      //Either generate it...
      default operator ?

      default operator $

      //...or write it in full, without 'default'

      operator $$ as pure
        <- rtn as JSON: JSON("text", JSON(text))

Questions and answers

These Q&A entries show E07230 and its fix:

Found a problem?

If EK9 reported E07230 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.