Control flow
Platform spec node
Control flow
Spec standingStandard
No architecture decision records under adr/ for this feature yet. Standard features must
publish at least one ADR or keep a ## Decisions summary on the hub.
- Control flow Conditionals, loops, and structured control transfer. Lowering to HIR/CLIF follows the evaluation order defined here.
- Events Multicast events, subscription lifetime, and thread affinity assumptions. UI stacks build on these primitives.
- Lambdas and closures Capture lists, environment layout, and lifetime of delegates. JIT and AOT must agree on closure calling conventions.
0 revisions (git unavailable at build; counts may be empty)
No commits recorded for this path.
| Section id | Required | Found |
|---|---|---|
scope | yes | yes |
features | yes | yes |
Full tree: run pnpm verify:platform-spec-layout (writes src/generated/platform-spec-layout-report.json).
Normative specification
Section titled “Normative specification”Defines statement-level control flow and structured transfer. Expression-level match is in Enums and match.
Statements
Section titled “Statements”| Construct | Rule |
|---|---|
if (cond) block else block | cond must be bool (non-bool condition diagnostic) |
while (cond) block | cond must be bool; body may loop |
for id in expr block | expr must be iterable per type rules (v0.1: range and array-like forms as implemented) |
return expr?; | Returns from the innermost function; expr must match return type when present |
break; / continue; | Must appear inside a loop; otherwise E1401 / E1402 |
let / typed let | Introduces locals; see Type inference |
Evaluation order
Section titled “Evaluation order”- Function arguments must be evaluated left to right before the call.
- Binary operators must evaluate left operand before right for
&&and||with short-circuit semantics. - Assignment must evaluate the right-hand side before storing.
Static rules
Section titled “Static rules”- Unreachable code after unconditional transfer may warn (W1403).
- HIR lowering must normalize control flow graphs (E1154 if non-normalized).
Dynamic semantics
Section titled “Dynamic semantics”ifandwhileexecute the taken branch block sequentially.breakexits the innermostwhile/for;continuejumps to the next iteration.
Diagnostics
Section titled “Diagnostics”Control band E1401–E1403; bool condition errors in type band. Registry: Diagnostic code registry.
Conformance
Section titled “Conformance”L3 semantic tests for break/continue and return paths must pass.
Decisions
Section titled “Decisions”- D-LM-CF-001 — No
switchstatement: Sum-type branching usesmatchexpressions only. - D-LM-CF-002 — Short-circuit booleans:
&&and||are mandatory short-circuit operators. - D-LM-CF-003 —
boolconditions only:if/whilemust not treat non-bool values as truthy (no C-style0truthiness). - D-LM-CF-004 — Structured transfer only:
gotois not in the grammar; usebreak/continue/return.
Platform view
Section titled “Platform view”Conditionals, loops, and structured control transfer. Lowering to HIR/CLIF follows the evaluation order defined here.