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

45 lines
1.1 KiB
Rust

// Quick Reference §3: statements and expressions.
// expect: run
// result: 50
// phase: 6
// spec: docs/agent/quick-reference.md
module demo.statements
enum Message {
Stop,
Value(u64),
}
fn main() -> u64
effects []
{
let a = 20u64;
let b = 22u64;
let c = a < b;
let d = false;
let t = 1u8;
let n = 4usize;
let m = Message::Value(7);
var acc: u64 = 0;
let x = a + b; // immutable
var i: usize = 0; // variable; reassign with i = i + 1;
var buf: [u8; 16] = zero; // zero-initialized storage
if c { acc = acc + 1; } else if d { acc = acc + 2; } else { acc = acc + 3; }
while i < n { i = i + 1; buf[0] = 1; }
for k in 0..n { acc = acc + k as! u64; }
loop {
i = i + 1;
if i > 6 { break; }
if i == 5 { continue; }
acc = acc + 1;
}
let y = if c { 1 } else { 2 };
let w: u64 = match m {
Message::Stop => 0,
Message::Value(v) => v,
};
match t { 0 => { acc = acc + 100; } 1 => { assert(acc + buf[0] as u64 == 9); } _ => { trap; } }
assert(c);
return x + y + w;
}