E50100: incompatible category
What went wrong
There's a mismatch in type categories. 'Category' is a classification within a genus - more specific than genus (see E50020). The usual case is a GENERIC type or function (a template) used where a concrete one is needed: 'Shouter() extends Transformer' instead of a parameterisation, or a generic class named in a trait's 'allow only' list.
Worked examples
Compilable examples demonstrating this error and the correct fix:
- ek9 -q 58 (How do generic functions work in EK9?)
How to fix it
- Review the expected type category for the context
- Classes use 'with trait of' for traits, 'extends' for classes
- Records extend records, not classes
- Check generic 'constrain by' clauses for category requirements
- A named function cannot extend a generic function, not even a parameterisation of it ('Shouter() is Transformer of (String, String)' is a syntax error); a DYNAMIC function can be one: rtn: () is Transformer of (String, String) as function
Common causes
- Extending a generic type or function without parameterising it
- Type hierarchy mismatch (extending wrong category)
- Generic constraint violation
- Using wrong type category in inheritance
See also
Examples
Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.
Fails with E50100: incompatible category
#!ek9 defines module error.e50100.bad defines function Transformer() of type (K, V) as abstract -> item as K <- rtn as V? Shouter() extends Transformer -> text as String <- rtn as String: text.upperCase()
Fixed: Parameterise the generic - a dynamic function can be one
#!ek9 defines module error.e50100.good defines function Transformer() of type (K, V) as abstract -> item as K <- rtn as V? shouter() <- rtn as Transformer of (String, String): () is Transformer of (String, String) as function rtn: item.upperCase()
Questions and answers
These Q&A entries show E50100 and its fix: