continue
continue inside a when body does not route to end. It skips to the
loop's back-edge and re-tests the condition, exactly as in any loop — and
crucially, it does not set the broke flag. A loop that continues on one pass
can still exit cleanly on a later pass and reach then.
when (i < 3i32) {
i = i + 1i32;
if (i == 1i32) { continue; } // skip the rest of pass 1
// ... passes 2 and 3 run fully ...
} then {
result = 2i32; // runs: the loop still exited cleanly
} end {
result = 3i32;
}
Here the first pass continues early, but passes two and three complete and the
condition then goes false. Because a body iteration reached the back-edge
(completed is true) and nothing broke, the loop lands in then.
continue does not, by itself, mark completion
The completed flag is set when an iteration reaches the back-edge normally —
a continue jumps to the back-edge but is treated as "this pass did not
finish". So a when whose every pass continues never sets completed, and
therefore routes to end:
when (a < 3i32) {
a = a + 1i32;
continue; // every pass bails before the back-edge
} then {
r = 2i32; // skipped
} end {
r = 3i32; // runs: no pass ever completed
}
This is consistent with the zero-iteration rule in
then and end semantics: if no iteration ever runs to
completion, the loop did not do its work, so end is the right destination.
Mental model
Think of continue as "try again" and break as "give up":
break→broke = true→ alwaysend.continue→ re-test the condition;completedonly flips on a full pass.- a normal full pass →
completed = true; a later clean exit →then.