Files
aji/tests/conformance/source/quickref/tasks.aji
T
dev 3e2d9b63a7 P6A-8: Source Reference Bundle and harness profile aji_source
- 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
2026-10-05 13:16:51 +03:00

41 lines
1.0 KiB
Rust

// Quick Reference §7: a scope with two tasks over disjoint halves (layer 7).
// expect: run
// result: 30
// phase: 6
// spec: docs/agent/quick-reference.md
module demo.qrtasks
fn square(s: slice_mut<u64>) -> u64
effects []
{
var sum: u64 = 0;
for i in 0..s.len {
s[i] = s[i] * s[i];
sum = sum + s[i];
}
sum
}
fn main() -> u64
effects [task.spawn, task.wait]
{
var data: [u64; 8] = [1; 8];
data[4] = 2;
data[5] = 2;
data[6] = 2;
data[7] = 4;
var total: u64 = 0;
{
mut d = data; // data: [u64; 8]
scope s { // every task spawned in s must be joined before the block ends (E4301)
let (l, r) = d.split_at(4);
let a = task.spawn(s, square, l); // borrows are lent to the task until its join
let b = task.spawn(s, square, r);
let x = task.join(move a);
let y = task.join(move b);
total = x + y;
}
}
total
}