How does EK9 detect duplicate trait references and service path conflicts?
← Code Quality · Ref: Q740
EK9 detects three categories of structural duplication at compile time.
DUPLICATE TRAIT REFERENCE (E02050)
Listing the same trait multiple times in a 'with trait of' clause is redundant and indicates a mistake. Each trait should appear exactly once.
SERVICE PATH DUPLICATION (E02070)
Two service operations cannot share identical HTTP method and path pattern combinations. Even if the path variable names differ, the routing structure is the same and creates ambiguity.
DELEGATE METHOD NAME CLASH (E02080)
A function delegate field cannot have the same name as a method in the same class. The compiler cannot distinguish between calling the delegate and calling the method.
See Q93 for class traits. See Q657 for service URI mapping.
Example
defines module qa.codequality.duplicatetraits defines trait Printable show() as abstract <- rtn as String? Describable describe() as abstract <- rtn as String? defines class Item with trait of Printable, Describable name <- String() Item() -> name as String this.name: name override show() <- rtn as String: name override describe() <- rtn as String: `Item: ${name}` default operator defines program DuplicateTraitsDemo() stdout <- Stdout() item <- Item("Widget") stdout.println(item.show()) stdout.println(item.describe())
Common mistakes
E02050 — The same trait 'Printable' is listed twice. Each trait should appear only once in the 'with trait of' clause. See ek9 -h E02050 for details.
Incorrect:
Item with trait of Printable, Printable
Correct:
Item with trait of Printable, Describable
E50060 — EK9 has no toString() method. Use the show() method or string interpolation. See ek9 -h E50060 for details.
Incorrect:
stdout.println(item.toString())
Correct:
stdout.println(item.show())
E50060 — The method is describe(), not getDescription(). EK9 does not use Java-style getter naming. See ek9 -h E50060 for details.
Incorrect:
stdout.println(item.getDescription())
Correct:
stdout.println(item.describe())
Other ways to ask this
- What is E02050 duplicate trait reference in EK9?
- What is E02070 service HTTP path duplicated in EK9?
- What is E02080 delegate and method name clash in EK9?
Coming from another language?
Java: duplicate interface implementation silently ignored. Python: no trait concept, multiple inheritance. Rust: duplicate trait bounds produce errors. Go: duplicate interface embedding is valid. Spring Boot: duplicate path mappings fail at runtime. EK9: all three detected at compile time.
Keywords: E02050, method, trait, E02070, delegate, clash, service, E02080, duplicate, path, quality