Class OrderingTotality

java.lang.Object
org.ek9lang.compiler.phase5.OrderingTotality

final class OrderingTotality extends Object
THE compile-time check that a hand-written <=> orders every two SET values of its type (E07188; Steve, 2026-10-21, sameness stock-take 4.4: "This is a closed system and we already have code that detects the subtypes").

The rule. A hand-written <=> is PARTIAL when the Integer it returns can come from a source that is unset for two set values. The sources of the returning variable are its initialiser and every assignment to it (and, through a local variable, that variable's own sources); a source is partial when it is

  • an UNSET construction - Integer() - a result a <=> names by its own choice (... else Integer());
  • a <=> of a type whose <=> is partial (PartialOrdering.whyPartial(ISymbol, ISymbol)): Money (one currency) or Dimension (one suffix), declared on the type; a type whose values can be of different run-time types under a per-type sameness (an open or abstract type - D24, extended 2026-10-27); or a user type's hand-written <=> that is itself partial (the sub-type analysis: the call resolves to the very <=> that runs); a DEFAULTED <=> is never a source here - over a partial field it is withdrawn (Sameness.orderingSurvives(MethodSymbol, ISymbol)) and a use of it is E07620;
  • a call of a method, operator or function whose own Integer result comes from such a source (followed through the callable's own sources, to any depth; a cycle is assumed total).

A path that leaves the result unassigned is not asked here: E08050 already refuses it for a returning variable with no initialiser. The check is flow-INSENSITIVE on purpose (no second flow engine, simple to explain): a partial source guarded by a test is still reported - write the result so that no source can be unset.

Collected per source (OrderingResultSources, parallel), decided once every source has been walked: a callee in another file is read from here, not from its parse tree; the verdicts are one least fixed point over every recorded callable (partialReasons()). Residual (documented, runtime backstop kept): a <=> over a bare generic T, a field's <=> that is an Optional or Dict entry, and a hand-written ? that calls a value set while a field is unset.

  • Constructor Details

    • OrderingTotality

      OrderingTotality()
  • Method Details

    • record

      void record(ISymbol callable, List<OrderingTotality.Finding> found)
      Record the partial sources of one callable's Integer result; nothing is recorded for a total one.
    • check

      void check(Function<IToken, ErrorListener> listenerFor)
      Report every hand-written <=> (a type's own sameness) whose result can be partial.
      Parameters:
      listenerFor - the error listener of the source a token belongs to