Files
aji/tests/conformance/source/layer1/control_flow.aji
T
dev ba3e9b3719 Phase 6A: .aji frontend, layer 1 (scalars, expressions, functions, control flow)
src/frontend: lexer, AST, parser for the full 6A grammar (first error
only: one E7001 with span, expected and found), lowering to canonical
text AIR with a line map. Variables become SSA with block parameters
carried across if/while/for/loop joins; short-circuit and/or; checked,
wrapping and cast forms; calls; untyped let literals typed from later
uses, never guessed (E7007). The frontend repairs nothing.

check.checkFile: .aji → frontend → existing AIR parser and verifier;
every diagnostic at its source location, AIR location kept as
air_line/air_col; trap records gain source_location. CLI: check/run on
.aji, aji lower [--annotate].

Runner: .aji tests with the same headers; every accepted module must
lower deterministically, be canonical (lower → parse → print
unchanged) and match <file>.expected if present. Layer-1 tests: 6 run,
6 E7xxx rejects, 2 verifier-caught (E1002, E3101).
2026-10-05 11:23:18 +03:00

30 lines
629 B
Rust

// while, for, loop, break, continue, if as an expression and variables carried across joins.
// expect: run
// result: 1062
// phase: 6
// spec: docs/spec/15-source-language.md
module demo.control
fn main() -> u64
effects []
{
var evens: u64 = 0;
for i in 0..10u64 {
if i % 2 == 1 { continue; }
evens = evens + i;
}
var n: u64 = 0;
var steps: u64 = 0;
while n < 1000 {
n = n + 37;
steps = steps + 1;
}
var k: u64 = 0;
loop {
k = k + 1;
if k == 5 { break; }
}
let big = if steps > 20 { 1 } else { 0 };
return evens + n + k + big;
}