- source bundle: a /docs directory with QUICK.md (Quick Reference plus a where-to-read table), language/*.md, diagnostics/errors.md and the AIR bundle only under air/; built from docs/agent/source-bundle.txt (> output files, @manifest includes) by zig build agent-reference - Quick Reference examples are checked: every aji block must be an excerpt of a conformance program in tests/conformance/source/quickref (zig build test fails otherwise); QR fixes found by the check (mut d = data, region not auto-borrowed, statement/borrow blocks that could not verify, io_error match) - frontend: task.*/channel.*/mutex.* are not-yet-implemented, not E7006 - aji lower --stats: mechanical_air_eliminated_raw and _normalized (each byte-string materialization counted as one constant; spec 15 §11) - harness: profile aji_source (doc_groups), per-file and per-group docs metrics on distinctive lines, profile columns (tool calls, lowered AIR raw/normalized, docs files read, IR-form and type-mismatch counts), dev-echo aji_source variant, scripted run and test, source token report - plan: P6A-8 done, P6A-9 criteria; Q-021/Q-022 resolved; unsafe block deferred
36 lines
1.3 KiB
Rust
36 lines
1.3 KiB
Rust
// Quick Reference §7: select over a receive and a send (layer 8).
|
|
// expect: run
|
|
// grant: heap=mem.alloc:1024
|
|
// result: 1
|
|
// phase: 6
|
|
// spec: docs/agent/quick-reference.md
|
|
module demo.qrselect
|
|
|
|
fn main(heap: cap<mem.alloc>) -> u64
|
|
effects [mem.alloc, task.wait]
|
|
{
|
|
let job = 9u64;
|
|
var which: u64 = 0;
|
|
match channel.make<u64>(1, heap) {
|
|
ok(tx_a, rx_a) => {
|
|
match channel.make<u64>(1, heap) {
|
|
ok(tx_b, rx_b) => {
|
|
channel.close_sender(move tx_a);
|
|
select {
|
|
recv(rx_a) { ok(x) => { which = 2; } closed => { which = 1; } }
|
|
send(tx_b, move job) { ok => { which = 1; } closed(job) => { which = 3; } }
|
|
cancelled(job) => { trap; }
|
|
}
|
|
channel.close_sender(move tx_b);
|
|
match channel.close_receiver(move rx_a) { ok => {} pending(rx_a) => { trap; } }
|
|
match channel.recv(rx_b) { ok(v) => {} closed => {} cancelled => { trap; } }
|
|
match channel.close_receiver(move rx_b) { ok => {} pending(rx_b) => { trap; } }
|
|
}
|
|
err(e) => { trap; }
|
|
}
|
|
}
|
|
err(e) => { trap; }
|
|
}
|
|
which
|
|
}
|