Files
aji/tests/conformance/source/quickref/region.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

24 lines
561 B
Rust

// Quick Reference §6: allocation in a region with an explicit region borrow.
// expect: run
// grant: heap=mem.alloc:256
// result: 2
// phase: 6
// spec: docs/agent/quick-reference.md
module demo.qrregion
fn main(heap: cap<mem.alloc>) -> u64
effects [mem.alloc]
{
let r = region.create(heap) or trap;
var v: u64 = 0;
{
ref arena = r;
let item = region.new(arena, 1u64) or trap; // item: mut<u64>, ends with this block
*item = *item + 1;
v = *item;
}
region.reset(r);
region.destroy(move r);
v
}