✓
Passing This code compiles and runs correctly.
Code
// MIRROR of 460_005_cell_capture_typed_record: a `std/cell:capture`
// transaction whose proto, open and capture all live in an imported module.
//
// capture's transform rewrites its containing flow into a record transaction;
// relocated into a module, the `! as` binding and the `captured { f: expr }`
// blocks must still resolve against the proto-typed record — the shape
// grammar aimed at a cell across the boundary.
import app/lib
app/lib:run()
Supporting Files
import std/io
import std/cell
import std/proto
import std/runtime
std/proto(room_state) {
visits: u32
name: string
}
pub tor greet { name: string } -> string
greet -> name
std/runtime:register(scope: "cell") {
greet(5)
}
pub tor run {}
run = std/cell:open(room_state, id: "room-7")
| cell c |> std/cell:capture(c, shape: room_state)
! as s |> std/cell:captured { visits: s.visits + 1 }
|> std/cell:captured { name: "assistant-01" }
| captured f |> std/io:print.ln("captured: visits={{ f.visits:d }} name={{ f.name:s }}")
|> std/cell:hibernate(c) |> std/io:print.ln("room-7 hibernated")
Actual
captured: visits=1 name=assistant-01
room-7 hibernated
Expected output
captured: visits=1 name=assistant-01
room-7 hibernated
Flows
flow ~run click a branch to expand · @labels scroll to their anchor
run
Test Configuration
MUST_RUN