E01090: is the name of a built-in construct; a second meaning for that name is not allowed

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

What went wrong

A construct is named after a built-in construct. No construct of any kind - class, record, trait, component, function, enumeration or other type, text, service, application, program or constant - may take the name of a construct from a built-in module such as org.ek9.lang.

The built-in modules are visible in every source file without being imported, so a user class called 'Date' would give 'Date' two meanings in one program. Which one a line means would depend on where you happen to be reading - a trap for a person and more so for an AI generating or reviewing code. EK9 removes the second meaning rather than asking you to keep track of it.

No list of names is involved: before a construct is defined its name is resolved, and if that finds a built-in construct this error is reported. Every current and future built-in is covered.

Worked examples

Compilable examples demonstrating this error and the correct fix:

  • ek9 -q 1389 (Can I name my own class, record, enumeration or function after a built-in type?)

Common causes

  • An enumeration of colours called Colour, or a record of money called Money
  • Naming a domain type after the built-in it wraps (Date, Duration, Version, Path)
  • A program named after what it prints to, such as Stdout
  • A constant named after its type, such as String

How to fix it

Give the construct a name that says what YOUR construct is: Hue or TrafficLight rather than Colour, Amount or Price rather than Money, AppointmentDate rather than Date. The built-in stays available and unambiguous alongside yours. Variables are not affected - a variable called 'colour' is fine.

The [EXAMPLE] section below shows one construct of every kind named after a built-in, then the same module with each renamed for what it is.

See also

  • E01091: A type parameter name that resolves to an existing construct
  • E01089: A name differing only by case from another construct in the module
  • E01040: Duplicate TYPE definition

Examples

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

Fails with E01090: is the name of a built-in construct; a second meaning for that name is not allowed

#!ek9
defines module error.e01090.bad

  defines constant
    String <- "shadow"

  defines type
    Colour
      Red
      Green

  defines record

    Money
      amount as Integer: 0

      default operator ?

  defines trait

    Comparator
      describe() as pure
        <- rtn as String: "trait"

  defines class

    Boolean
      flag as String: "x"

      default operator ?

  defines function

    Supplier()
      <- rtn as String: "supplied"

  defines component

    Iterator
      describe() as pure
        <- rtn as String: "component"

  defines text for "en"

    Exception
      greeting()
        "Hello"

  defines application

    Networking
      stdout <- Stdout()

  defines program

    Stdout()
      value <- "program"
      require value?

Fixed: Name each construct for what it is in your domain, never after a built-in

#!ek9
defines module error.e01090.good

  defines constant
    Greeting <- "shadow"

  defines type
    PaintColour
      Red
      Green

  defines record
    Payment
      amount as Integer: 0
      default operator ?

  defines trait
    Describable
      describe() as pure
        <- rtn as String: "trait"

  defines class
    Switch
      label as String: "x"
      default operator ?

  defines function
    nameSupplier()
      <- rtn as String: "supplied"

  defines component
    Cursor
      describe() as pure
        <- rtn as String: "component"

  defines text for "en"
    Messages
      greeting()
        "Hello"

  defines application
    Console
      stdout <- Stdout()

  defines program
    Printer()
      stdout <- Stdout()
      stdout.println(Greeting)

Questions and answers

These Q&A entries show E01090 and its fix: