Represents information about what control effects a do block has.
The fields split by flavor:
breaks,continues,returnsEarly, andreassignsare syntactic:true/non-empty iff the corresponding construct appears anywhere in the source text of the block, independent of whether it is semantically reachable. Downstream elaborators must assume every such syntactic effect may occur, because the elaborator visits every doElem (only top-levelreturn/break/continueshort-circuit viaelabAsSyntacticallyDeadCode).numRegularExitsis also syntactic: the number of times the block wires the enclosing continuation into its elaborated expression.withDuplicableContreads it as a join-point duplication trigger (> 1).noFallthrough = trueasserts that the next doElem in the enclosing sequence is semantically irrelevant (control never falls through to it).noFallthrough = falsemakes no such assertion. The dead-code warning fires on the next element when this istrue.
Invariant: numRegularExits = 0 → noFallthrough. The converse does not hold.
- breaks : Bool
The
doblock syntactically contains abreak. - continues : Bool
The
doblock syntactically contains acontinue. - returnsEarly : Bool
The
doblock syntactically contains an earlyreturn. - numRegularExits : Nat
The number of times the block wires the enclosing continuation into its elaborated expression. Consumed by
withDuplicableContto decide whether to introduce a join point (> 1). - noFallthrough : Bool
When
true, asserts that the next doElem in the enclosing sequence is semantically irrelevant (control never falls through to it).falseasserts nothing. - reassigns : NameSet
The variables that are syntactically reassigned somewhere in the
doblock.
Instances For
Equations
Equations
Instances For
The identity of ControlInfo.alternative: a ControlInfo describing a block with no branches
at all (so no regular exits and the next element is trivially unreachable).
Equations
- Lean.Elab.Do.ControlInfo.empty = { numRegularExits := 0, noFallthrough := true }
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
A handler for inferring ControlInfo from a doElem syntax. Register with @[doElem_control_info parserName].
Equations
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Registers a ControlInfo inference handler for the given doElem syntax node kind.
A handler should have type ControlInfoHandler (i.e. TSyntax \doElem → TermElabM ControlInfo). For pure handlers, use fun stx => return ControlInfo.pure`.