cli: map block diagnostics to their source constructs

This commit is contained in:
dev committed 2026-10-07 21:45:57 +03:00
1 parent 1495650587
commit 1a80c42289
30 files changed
+555 -27

No files matched your search

+11 -1
View File
@@ -136,7 +136,7 @@ Lowering layers (P6A-3/4), each with accepted (golden AIR), rejected (`E7xxx`) a
| P6-4 | done (RFC 0022 Implemented) | Type checking and monomorphized generics with structural constraints (`Copy`, `Send`, `Share`, `Freeze`, `Local`) | P6-3 | `src/frontend/generics.zig`, spec 15 §15 | generic code instantiates deterministically; constraint violations diagnosed |
| P6-5 | todo | Lowering to AIR: control flow, `?`, `defer` cleanup edges, borrow blocks, task scopes | P6-4 | `src/frontend/lower.zig` | lowered AIR verifies; lowering is a pure function (same input ⇒ same AIR bytes) |
| P6-6 | todo | Contracts: `requires`/`ensures`/invariants → contract table; status classification | P6-5 | frontend + verifier | each contract reported as PROVEN_STATICALLY / CHECKED_AT_RUNTIME / ASSUMED_UNSAFE / UNPROVEN |
| P6-7 | todo | Source spans in diagnostics for verifier errors on lowered AIR | P6-5 | `src/diag.zig`, lowering | every conformance reject test has a source-level twin with the same code |
| P6-7 | doing | Source spans in diagnostics for verifier errors on lowered AIR | P6-5 | `src/diag.zig`, lowering | every conformance reject test has a source-level twin with the same code |
| P6-8 | done | Formatter for implemented source syntax | P6-2 | `aji fmt`, spec 15 §11 | token/comment/declaration preservation; idempotence, identical AIR and CLI write/check tests |
| P6-9 | done | Port reference programs and examples to `.aji` | P6-5 | `tests/conformance/source/programs/`, `examples/` | all five source/AIR reference pairs and every example source/package pass |
| P6-11 | done (implementation; RFC 0036 Proposed) | Source functions/calls returning borrows with explicit `from` origin; Q-034 | P6-3/4 | spec 15, binding/call/return lowering, Quick Reference and source/AIR conformance | origin/lifetime and temporary-end rules specified; valid/rejected returned views use existing verifier/interpreter semantics |
@@ -204,3 +204,13 @@ The implementation follow-up from P6-9 is resolved: nominal values and `ref`/`mu
Existing borrow/load/end and whole-value ownership rules remain authoritative: reading a Copy field succeeds, conflicting borrows reject E2101, and projecting a linear field rejects E1001. Missing struct fields now produce E7002 with `type` and `field`, replacing the misleading array/slice E7005. Enum field access and type mismatches retain E7005. A struct length field does not prove slice bounds: the out-of-bounds regression still traps T0008. This restores specified source behavior without changing accepted AIR semantics or runtime state.
Validation: full conformance passes 1,201/1,201, including all 15 new cases; the new cases also pass with collection before every instruction. Unit tests, generic CLI integration (32 checks), formatting checks and coverage (120/120) pass. The formatter passes 3,437 checks over 916 public files, with 582 identical successful AIR outputs. Imported generic fields preserve declared types, source locations and source/AIR run-record parity. Across 1,233 original public files, all 2,134 check/lower results agree after normalizing absolute versus relative diagnostic file paths; all 570 successful source lowerings are byte-identical. Independent read-only Claude review found no remaining issues. P6-5 remains open for its other source-layer work.
## P6-7 block positions and lifetime twins (2026-10-07)
Generated block labels now carry the explicit source span of their creating construct, including branch joins, loop headers/exits/steps and short-circuit expressions. E3002 at a resource-state join therefore identifies the source construct instead of falling back to 1:1. Annotations expose label positions; canonical AIR and verifier/runtime rules are unchanged. Existing source-location deduplication now preserves errors on distinct constructs. The borrowed-buffer-element fixture consequently expects both allocation and destruction diagnostics.
Eight Phase 2 AIR rejection twins and five successful source runs cover owner/region/resource lifetimes and explicit release. Eleven further rejects cover every join form and distinct diagnostics. The CI CLI suite checks exact primary/AIR positions, label annotations, code parity and imported generic provenance. Existing ownership and borrow invariants, explicit cleanup and deterministic execution remain authoritative; no spec, diagnostic code, bundle or evaluation input changes. P6-7 remains open for the remaining twins.
Validation: unit tests and full conformance pass, 1,225/1,225; all 24 new cases pass with per-instruction collection. Lifetime CLI checks pass 188 assertions, related-location checks 301, coverage 120/120 and formatting checks pass. The formatter checks 940 public files with 606 identical AIR outputs. Across 916 original public sources, check outcomes and all 421 accepted canonical AIR outputs are unchanged; four diagnostic outputs gain source positions, one also recovering a previously suppressed error. Independent read-only Claude review found no remaining issues.
Next P6-2 follow-up: capture full parser spans after parsing block/unary operands. Current annotated ranges can end before an `if` starts; this is separate from the primary-position correction above.