✓
Passing This code compiles and runs correctly.
Code
// std/channel — the select answer: two channels joined to one pump, each
// with its own consumer arm. The pump steps both participants in join
// order — a statically resolved multi-channel wait with no runtime
// `selectgo`. One value per channel, both close, pump drains.
import std/io
import std/proto
import std/channel
import std/pump
std/proto(Reading) {
id: u64
ts: f64
}
pub tor mk-reading { i: u64, t: f64 } -> Reading
mk-reading -> { id: i, ts: t }
std/channel:new(left, capacity: 8) { reading: Reading }
std/channel:new(right, capacity: 8) { reading: Reading }
std/channel(left)
! reading v |> std/io:print.ln("left {{ v.id:d }}")
std/channel(right)
! reading v |> std/io:print.ln("right {{ v.id:d }}")
mk-reading(i: 100, t: 1.0): a |> std/channel:send(left, a)
| ok |> mk-reading(i: 200, t: 2.0): b |> std/channel:send(right, b)
| ok |> std/channel:close(left)
| ok |> std/channel:close(right)
| ok |> std/io:print.ln("both sealed")
| full |> std/io:print.ln("send2 full")
| closed |> std/io:print.ln("send2 closed")
| full |> std/io:print.ln("send1 full")
| closed |> std/io:print.ln("send1 closed")
std/pump:create(main)
| drained |> std/io:print.ln("pump drained")
std/pump(main)
! step |> left-step()
! live |> left-live()
std/pump(main)
! step |> right-step()
! live |> right-live()
std/pump:run(main)
Actual
both sealed
left 100
right 200
pump drained
Expected output
both sealed
left 100
right 200
pump drained
Flows
flow ~std/proto click a branch to expand · @labels scroll to their anchor
std/proto (Reading, source: id: u64
ts: f64)
flow ~new click a branch to expand · @labels scroll to their anchor
new (expr: left, capacity: 8, source: reading: Reading)
flow ~new click a branch to expand · @labels scroll to their anchor
new (expr: right, capacity: 8, source: reading: Reading)
flow ~std/channel click a branch to expand · @labels scroll to their anchor
std/channel (left)
flow ~std/channel click a branch to expand · @labels scroll to their anchor
std/channel (right)
flow ~mk-reading click a branch to expand · @labels scroll to their anchor
mk-reading (i: 100, t: 1.0)
flow ~create click a branch to expand · @labels scroll to their anchor
create (expr: main)
flow ~std/pump click a branch to expand · @labels scroll to their anchor
std/pump (main)
flow ~std/pump click a branch to expand · @labels scroll to their anchor
std/pump (main)
flow ~run click a branch to expand · @labels scroll to their anchor
run (main)
Test Configuration
MUST_RUN