✓
Passing This code compiles and runs correctly.
Code
// PINS: `clear` refuses a store whose observer would silently stop being told.
//
// A `! removed` arm is a per-row observer. `clear` does not fire it — firing
// it once per row is exactly the cost `clear` exists to remove — so a store
// carrying one must also declare `! cleared` to say what emptying means for
// its observers. Refusing is the only honest option: emptying the store while
// quietly skipping the arm would leave the observer's own bookkeeping wrong
// with nothing on screen to say so.
//
// The diagnostic names THIS cause specifically. The sibling refusal — an
// owned column, whose obligations discharge one at a time — has its own
// message, because a store hitting one of these should not be sent to read
// about the other.
import std/io
import std/store
std/store:new(t) { n: 0[i64] }
std/store:new(rows, capacity: 4) { v: i64 }
! removed _ |> std/store:stored { t.n: t.n - 1 }
std/store:insert(rows) { v: 1 }
| row _ |> _
| full |> _
std/store:clear(rows)
std/io:print.ln("n {{ t.n:d }}")
Output must match:
MUST_ERROR
CONTAINS carries a `! removed` arm and no `! cleared` arm
CONTAINS does NOT fireFlows
flow ~new click a branch to expand · @labels scroll to their anchor
new (expr: t, source: n: 0[i64])
flow ~new click a branch to expand · @labels scroll to their anchor
new (expr: rows, capacity: 4, source: v: i64)
flow ~insert click a branch to expand · @labels scroll to their anchor
insert (expr: rows, source: v: 1)
flow ~clear click a branch to expand · @labels scroll to their anchor
clear (expr: rows)
flow ~print.ln click a branch to expand · @labels scroll to their anchor
print.ln (expr: "n {{ t.n:d }}")