Why does EK9 reject the same symbol listed twice in a references block?
← Syntax and Structure Rules · Ref: Q1307
Each symbol may appear at most once in a module's references block. Listing the same module.path::Symbol twice (or two references that resolve to the same short name) triggers E03020 - conflicting references - because the second entry is redundant and usually signals a copy-paste mistake.
The fix is simple: keep one reference and delete the duplicate. If two genuinely different modules each export a type with the same short name, you cannot reference both; keep the more frequently used one in the references block and use the fully qualified module.path::Symbol form inline for the other.
See Q726 for module reference syntax. See Q851 for why references need the :: qualifier.
Example
defines module qa.syntax.duplicate.reference //THE FIX: each symbol appears in the references block exactly once. //Listing 'org.ek9.lang::List' twice would trigger E03020 (conflicting references). references org.ek9.lang::List defines program DuplicateReferenceDemo() stdout <- Stdout() //Short-name access via the single, non-duplicated reference. names <- List() of String names += "Alice" names += "Bob" stdout.println(`Names count: ${length names}`)
Common mistakes
E03020 — The same symbol 'List' is listed twice in the references block, so EK9 reports E03020 - the second entry conflicts with the first and is redundant. List every referenced symbol exactly once; if two different modules export the same short name, keep one in the references block and use the fully qualified module.path::Symbol form inline for the other. See ek9 -h E03020 for details.
Incorrect:
references org.ek9.lang::List org.ek9.lang::List
Correct:
references org.ek9.lang::List
Other ways to ask this
- What triggers E03020 conflicting references in EK9?
- Why can't I import the same type twice in EK9?
- How do I fix a duplicate reference in an EK9 references block?
Coming from another language?
Java: duplicate import statements compile and are at most an IDE/checkstyle warning. Python: a duplicate import silently re-binds the name with no diagnostic. Go: an unused import is an error but a redundant duplicate is deduplicated by tooling. Rust: a duplicate 'use' is an error (E0252/E0254). EK9: a duplicate references entry is a hard compile-time error (E03020) caught in the REFERENCE_CHECKS phase, so the redundancy can never reach a build.
Keywords: duplicate, references, module, conflict, syntax, E03020, reference, qualifier, import