Class ConstantArithmeticOrError

All Implemented Interfaces:
Consumer<EK9Parser.ExpressionContext>

final class ConstantArithmeticOrError extends TypedSymbolAccess implements Consumer<EK9Parser.ExpressionContext>
Detects arithmetic expressions that always produce a constant result (E08083).

Two sub-patterns are detected:

  • Self-arithmetic: same symbol on both sides of -, /, mod, or rem. For example x - x is always 0, x / x is always 1.
  • Trivial modular: right operand is integer literal 1 with mod or rem. For example x mod 1 is always 0.

x + x (valid doubling) and x * x (valid squaring) are NOT flagged.