E07030: 'default' of operators on a trait is not supported
What went wrong
You're trying to use 'default operator' in a TRAIT, but traits don't support auto-generated operators.
Worked examples
Compilable examples demonstrating this error and the correct fix:
- ek9 -q 116 (What does 'default operator' generate?)
How to fix it
- Move default operator to implementing class
- Or define abstract operator signature in trait
- Traits define interfaces, classes provide implementations
Common causes
- Treating trait like a class
- Trying to provide default behavior for operators
- Misunderstanding trait vs class capabilities
See also
Examples
Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.
Fails with E07030: 'default' of operators on a trait is not supported
#!ek9 defines module error.e07030.bad defines trait Describable describe() as pure abstract <- rtn as String? //A trait has no fields to generate an operator from default operator $
Fixed: Write the trait's operator, over the trait's own methods
#!ek9 defines module error.e07030.good defines trait Describable describe() as pure abstract <- rtn as String? //Give the trait's operator a body, written over the trait's own methods operator $ as pure <- rtn as String: describe()
Questions and answers
These Q&A entries show E07030 and its fix:
Found a problem?
If EK9 reported E07030 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.