Class NoBuiltInNameOrError

java.lang.Object
org.ek9lang.compiler.support.NoBuiltInNameOrError
All Implemented Interfaces:
BiPredicate<IScope,ISymbol>

public final class NoBuiltInNameOrError extends Object implements BiPredicate<IScope,ISymbol>
THE check that a construct being defined in a user module does not take the name of a built-in construct (E01090). Every module-level definition goes through it - ModuleScope.defineOrError, and the text-base path in TextFactory that bypasses it.

No list of names is held: the name is RESOLVED, before the construct is defined, and rejected if it finds a construct from a core (implicitly imported) module - so org.ek9.math, or any construct later added to org.ek9.lang, is covered without change.

Why: the core modules are visible everywhere, so a user Date gives Date two meanings in one program. That confuses a reader or an AI, and it confused the compiler too - in SYMBOL_DEFINITION a later-declared user Date is not yet defined, so the name bound to the built-in and checks drew conclusions from the wrong type (front-end audit FE36, FE37, FE61). Removing the second meaning removes that whole class.

The core modules themselves are exempt: they ARE the built-ins.

  • Constructor Details

    • NoBuiltInNameOrError

      public NoBuiltInNameOrError(ErrorListener errorListener)
  • Method Details

    • test

      public boolean test(IScope moduleScope, ISymbol symbol)
      Check the symbol about to be defined in the module scope given. If this returns true then an error will have been added to the error listener.
      Specified by:
      test in interface BiPredicate<IScope,ISymbol>
      Parameters:
      moduleScope - the module scope the symbol is about to be defined in.
      symbol - the symbol about to be defined (not yet defined).