Class GuardVariableReadWhereUnsetOrError
- All Implemented Interfaces:
Consumer<EK9Parser.IfStatementContext>
<- guard's variable in a LATER else if / else
block of the same if chain, before anything assigns it there.
if v <- f() declares v for the whole chain, and every later block runs only because v was
unset - so a read there can only find nothing. Only a guard that is the WHOLE condition is provably unset: with a
then/with condition a later block also runs when v was set and the condition false, and a
Boolean truth guard (BooleanTruthGuard) also skips a set false. Neither is reported.
A WRITE stays legal - :=, =, :, :=? give v a value - and
a read after it is fine. "After" is source order within the later block (its pre-flow and condition included):
an assignment anywhere earlier in the block, even in a nested branch, means v is no longer PROVABLY unset,
and a read inside a loop that also assigns v may see the assignment from an earlier pass. Every other use
of v - a mutating operator such as += or :=:, a method call, an argument, a capture - is a
read.
-
Field Summary
Fields inherited from class RuleSupport
errorListener, symbolsAndScopes -
Constructor Summary
ConstructorsConstructorDescriptionGuardVariableReadWhereUnsetOrError(SymbolsAndScopes symbolsAndScopes, ErrorListener errorListener) -
Method Summary
-
Constructor Details
-
GuardVariableReadWhereUnsetOrError
GuardVariableReadWhereUnsetOrError(SymbolsAndScopes symbolsAndScopes, ErrorListener errorListener)
-
-
Method Details
-
accept
- Specified by:
acceptin interfaceConsumer<EK9Parser.IfStatementContext>
-