Class BooleanTruthGuard

java.lang.Object
org.ek9lang.compiler.support.BooleanTruthGuard

public final class BooleanTruthGuard extends Object
THE Boolean truth guard rule (Steve, 2026-10-07, decision D9.2) - use this, do not re-derive it.

An if or else if head whose pre-flow is a declaration guard (<-) or an assign-if-unset (:=?), and whose target's DECLARED type is exactly Boolean, enters only when the target is SET AND TRUE. Every other guard enters when its target is set. So if ok <- check() skips the body when check() returns false, exactly as a reader expects; before this rule a set false entered it.

Deliberately narrow:

  • Only if / else if (and their when spelling). A switch keeps enter-if-set, or its case false could never be reached; while, do, for and try keep enter-if-set too.
  • Only <- and :=?. A := head is blind (no gate at all).
  • Only a target whose type IS Boolean (by symbol identity, isExactSameType). A type that merely promotes to Boolean (#^) keeps enter-if-set; so does a generic's T, whatever it is parameterised with, because the declared type is T.

Phase 7 adds the _true() test to the guard's gate (GuardedConditionEvaluator); phase 5 narrows the target to true inside the body and does not narrow it to unset on the skip path (it may be false).