E01020: invalid module name

Category: E01xxx Parsing and excluded constructs · Reported in phase: SYMBOL_DEFINITION · Classification: INVALID_MODULE_NAME · All error codes

What went wrong

The module names of the EK9 core, org.ek9.lang and org.ek9.math, are reserved. User code cannot define a module with either name.

Worked examples

Compilable examples demonstrating this error and the correct fix:

  • ek9 -q 852 (Which module names are reserved in EK9?)

Reserved names

The rule is EXACT membership, not a prefix:

  • org.ek9.lang - Core language types (String, Integer, List, etc.)
  • org.ek9.math - Mathematical types and functions

Other names under org.ek9 (org.ek9.lang.custom, org.ek9.tools) are not reserved by this check - that namespace is where official libraries written in EK9 live.

How to fix it

Choose a different namespace for your module:

  • Use your organisation's domain (com.mycompany, net.example)
  • Use a project-specific prefix (myproject.utils)
  • Any name other than org.ek9.lang and org.ek9.math passes this check

Common causes

  • Attempting to extend built-in types by adding to reserved namespace
  • Copy-paste from documentation examples without changing namespace

Note

This restriction is enforced at compile time and cannot be bypassed.

Examples

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

Fails with E01020: invalid module name

#!ek9
defines module org.ek9.lang

  defines function

    helper()
      <- rtn as String: "only the compiler's bootstrap may define this module"

Fixed: Name the module for your own organisation; other org.ek9 names are allowed too

#!ek9
defines module error.e01020.good

  defines function

    helper()
      <- rtn as String: "a module of your own"

Questions and answers

These Q&A entries show E01020 and its fix:

Found a problem?

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