Class OperatorPurityCorrection

java.lang.Object
org.ek9lang.compiler.repair.OperatorPurityCorrection

public final class OperatorPurityCorrection extends Object
THE correction of a custom operator's as pure in source text the Oracle is about to write - use this, do not re-derive the rule from a list of symbols.

An operator's purity is not a choice. ValidOperatorOrError.populateOperatorChecks() wraps every operator in exactly one of two decorators: addPureCheck, meaning it MUST be declared as pure (E07500), or addNonPureCheck for the ten mutators :~: :^: :=: | += -= *= /= ++ --, which must NOT be (E07510). OperatorMap carries the same fact as markedPure and OperatorMapTest.markedPureMatchesPhaseTwo pins the two together. So there is exactly one legal spelling, the Oracle knows it, and a caller who wrote the other one did not mean a different program - they meant this one.

Why it is APPLIED rather than named. Measured on the tool-use harness: a run carrying at least one refusal averages 6.7 rounds against 2.4 for a clean one, ~2 rounds per refusal; and the one repair that already moved from named to applied (the unbalanced trailing bracket) took its task from a mean of 10.0 rounds over 30 runs to 2.8 over 24. A named fix lands on the next call 8 times in 9 - good, but it still costs the round, and the ninth burns several (create T2 on one arm resent the identical refused entry three times, then went raw and failed four more). The scaffolder has derived the E07500 direction since 2026-09-17, which is why E07500 fell to zero on the scaffolded path - but 11 E07500 and 5 E07510 were still measured afterwards, from raw write_file / edit_file text that never reaches the scaffolder. This class is that second half.

Deliberately conservative. Only a line that is ENTIRELY a custom operator declaration is touched - optional indent, optional override, operator, a known symbol, an optional as pure, nothing else. A default operator line is left alone (its purity is the compiler's to synthesise), as is any line with a body, a comment or a parameter on it. An unknown symbol is left alone: the compiler will reject it and say why.

  • Method Details

    • correct

      public static OperatorPurityCorrection.Result correct(String text)
      Correct every custom operator declaration in text whose as pure contradicts the language. Returns the original text and no notes when there is nothing to do.
    • correctedLine

      public static String correctedLine(String line)
      The corrected form of one line, or null when the line is not a custom operator declaration or already spells its purity the way the language fixes it.