Linearity rules
A variable of type Ctx<M> is live or moved. These rules apply, checked flow-sensitively along every path:
- Use moves. Any mention of a context variable in an expression moves it (contexts have no non-consuming uses). Using a moved variable is
V0101. - Everything is consumed. At the end of a scope, every context declared in it must be moved: dropped, returned, passed to a function, consumed by an operation, or committed. Otherwise
V0102. Discarding a context-valued expression (c ++ "x"as a statement) or binding it to_is alsoV0102. - No overwriting. Assigning to or shadowing a context variable that is still live would leak it:
V0102. - Branches agree. After
if/else, every pre-existing context has the same state on both paths (V0103). A path thatreturns is excluded from the comparison. - Loops are neutral. A loop body leaves every outer context in the state it found it, including its labelled spans (
V0104). - No hidden copies. A context can’t be stored inside a value that is then bound to a single name, like
let t = (c, 1)(V0105). Destructure instead:let (c, x) = .... Contexts can’t be printed. - Models match. Arguments, returns, and commits require the same model (
V0106). - Returns release. At
return, every context not being returned must already be consumed. - Speculation is a transaction. Inside
speculate, outer contexts are frozen (V0131), every path ends incommit/rollback(V0130),returnis forbidden (V0132), and contexts created inside are released automatically at the commit or rollback.
Each context type also carries two label sets: must (labels definitely present) and may (labels possibly present).
c ++ #[l] textrequiresl ∉ may(elseV0121) and addslto both.splice c at l with ...requiresl ∈ must(elseV0120) and removeslfrom both.with #[k] ...addsk.- At joins (after
if, speculation outcomes): must = intersection, may = union.