P6A-11, P6A-12: malformed lowering is an internal compiler error; source type-check completeness

P6A-11: when a .aji module passed the frontend but its AIR does not parse
(E0001-E0005) or has invalid SSA/CFG (E5001, E5002), the result is one
E7900 source.internal_compiler_error at the source construct, with the
AIR code in air_code; semantic codes (E0006 included) are unaffected.
Unit test injects the checkpoint's `ret %` defect.

P6A-12: source-decidable type errors are E7005 at the source:
- `as` checks lossless widening with the verifier's own rule (shared
  function), and that both sides are integers
- slice.copy element types; own.free / region.destroy operand types
- element rules of channel.make<T> and mutex.make (no borrow, scope,
  task, shield or guard, at any depth)
Probing every source position found no other E1001/E1002 leak. The old
test encoding the previous rule (verifier_widen, E1002) is replaced by
typecheck/lossy_widen (E7005); 9 typecheck tests. Spec 15 §10 states the
frontend/verifier boundary.
This commit is contained in:
dev committed 2026-10-05 18:10:53 +03:00
1 parent 154c39865f
commit 748eddf4e5
16 files changed
+249 -14

No files matched your search

+24
View File
@@ -360,8 +360,31 @@ A byte string or array used where a `slice<u8>` is expected is materialized in f
| found by the verifier on the lowered AIR | the AIR code; the diagnostic's `file`, `line` and `col` are the source location of the construct the instruction came from, and `air_line`/`air_col` locate it in the lowered AIR (`aji lower`); the verifier's own fields (`function`, `block`, `inst`) are kept |
| syntax, name resolution, lowering and invalid source constructs | `E7xxx`, below |
| several AIR instructions of one construct reporting the same code | one diagnostic (the first) per code and source location |
| the lowered AIR is malformed: a parse error (`E0001`–`E0005`) or invalid SSA or CFG (`E5001`, `E5002`) | `E7900` (`source.internal_compiler_error`) at the source construct, with the AIR code in `air_code`. It is a compiler bug, never an error in the program, and replaces every other diagnostic of the module. Semantic codes (ownership, borrows, resources, effects, capabilities, concurrency, `E0006`) are not affected |
| trap at run time | the trap record also carries `source_location` (`file`, `line`, `col`) |
**Which errors the frontend reports.** An error that is fully decided by source types is `E7005` (or another `E7xxx`) at the source construct, and never reaches the verifier as `E1001`/`E1002`. The frontend checks:
- the types of expressions, operands and results;
- arity and argument types of functions and built-in operations;
- the existence of fields and variants;
- `ref`/`mut` compatibility;
- lossless widening by `as` (the verifier's own rule);
- slice element types of `slice.copy`;
- the element rules of channels and mutexes (no borrow, scope, task, shield or guard).
The verifier remains the authority for:
- ownership state, linearity and moves;
- borrow conflicts and lifetimes;
- resource state;
- effects and capabilities;
- concurrency (loans, `Send`/`Share`, the critical-section rule);
- reserved features;
- every other verifier invariant.
Its diagnostics keep their AIR codes, reported at the source location.
| Code | Kind | Meaning |
|---|---|---|
| E7001 | source.syntax | Malformed `.aji` source |
@@ -371,6 +394,7 @@ A byte string or array used where a `slice<u8>` is expected is materialized in f
| E7005 | source.type_mismatch | Expression has the wrong type in a source position |
| E7006 | source.invalid_construct | Construct not allowed here (e.g. `break` outside a loop, `move` of a non-linear value, `zero` for a non-zeroable type) |
| E7007 | source.ambiguous | Source meaning cannot be determined (e.g. an integer literal with no type from context) |
| E7900 | source.internal_compiler_error | The frontend produced invalid AIR for this construct (a compiler bug, not a program error) |
## 11. Tooling