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).
This commit is contained in:
dev committed 2026-10-05 11:23:18 +03:00
1 parent bfb4c445cd
commit ba3e9b3719
26 files changed
+2478 -13

No files matched your search

@@ -0,0 +1,11 @@
// The frontend never guesses an integer type.
// expect: reject E7007
// phase: 6
// spec: docs/spec/15-source-language.md
module demo.ambiguous
fn main() -> void
effects []
{
let unused = 5;
}
@@ -0,0 +1,13 @@
// Only `var` can be reassigned.
// expect: reject E7006
// phase: 6
// spec: docs/spec/15-source-language.md
module demo.assign
fn main() -> u64
effects []
{
let x: u64 = 1;
x = 2;
return x;
}
@@ -0,0 +1,11 @@
// expect: reject E7006
// phase: 6
// spec: docs/spec/15-source-language.md
module demo.noreturn
fn main() -> u64
effects []
{
let x: u64 = 1;
if x > 0 { return x; }
}
@@ -0,0 +1,12 @@
// One precise syntax error, no cascade.
// expect: reject E7001
// phase: 6
// spec: docs/spec/15-source-language.md
module demo.syntax
fn main() -> u64
effects []
{
let a = 1
return a;
}
@@ -0,0 +1,11 @@
// expect: reject E7005
// phase: 6
// spec: docs/spec/15-source-language.md
module demo.mismatch
fn main() -> u64
effects []
{
let ok = true;
return ok;
}
@@ -0,0 +1,10 @@
// expect: reject E7002
// phase: 6
// spec: docs/spec/15-source-language.md
module demo.unknown
fn main() -> u64
effects []
{
return missing + 1;
}
@@ -0,0 +1,17 @@
// Effects stay explicit: the verifier reports E3101 at the call, with suggested_effects.
// expect: reject E3101
// phase: 6
// spec: docs/spec/15-source-language.md
module demo.effects
fn alloc_something() -> void
effects [mem.alloc]
{
return;
}
fn main() -> void
effects []
{
alloc_something();
}
@@ -0,0 +1,12 @@
// The frontend does not duplicate the verifier: a lossy `as` lowers to cast.widen and the verifier rejects it (E1002).
// expect: reject E1002
// phase: 6
// spec: docs/spec/15-source-language.md
module demo.widen
fn main() -> u8
effects []
{
let big: u64 = 1;
return big as u8;
}