✓
Passing This code compiles and runs correctly.
Code
// MIRROR of the `std/node(node)` bare-borrow form — the node:default
// transform — with the call site in an imported module.
//
// default rewrites `std/node(name)` into a node-self borrow; relocated into
// a module, the `| node f` arm's custody and the member-miss `not-found`
// arm must resolve identically.
import app/lib
app/lib:run()
Supporting Files
import std/io
import std/node
import std/cell
import std/proto
import std/runtime
std/proto(room_state) {
visits: u32
}
pub tor greet { name: string } -> string
greet -> name
std/runtime:register(scope: "cell") {
greet(5)
}
// The bare borrow, spelled two ways — each at the head of its own flow,
// which is the position std/node:default rules on.
pub tor borrow-node {}
borrow-node = std/node(node)
| node f |> std/io:print.ln("node borrowed")
pub tor borrow-member {}
borrow-member = std/node(node.absent-9)
| cell c |> std/io:print.ln("unexpected cell")
| held-by o |> std/io:print.ln("held by {{ o:s }}")
| not-found |> std/io:print.ln("absent-9 not found")
pub tor run {}
run = std/node:new(node, scope: "cell", world: "", capacity: 8)
|> borrow-node()
|> borrow-member()
|> std/node(node)
| node f |> std/node:drain(f): n |> std/io:print.ln("drained {{ n:d }} cell(s)")
Actual
node borrowed
absent-9 not found
drained 0 cell(s)
Expected output
node borrowed
absent-9 not found
drained 0 cell(s)
Flows
flow ~run click a branch to expand · @labels scroll to their anchor
run
Test Configuration
MUST_RUN