cli: index loop-exit edges and reuse negative After queries; fix loop-exit diagnostics (Q-063, Q-064)

This commit is contained in:
dev committed 2026-10-14 18:26:44 +03:00
1 parent 2fb882c704
commit 2d750a0525
15 files changed
+1016 -76

No files matched your search

+52 -11
View File
@@ -661,17 +661,30 @@ profiled targets accept normally. This is a finite Debug profile, not a
portable timing bound or a whole-compiler complexity proof.
Q-060's full per-step validation is now closed by its composite audit.
Profiling for Q-063 is complete for these paths; optimization remains open.
The recommended first isolated change is explicit loop incoming-edge metadata,
followed by context-correct liveness indexing and a separately reviewed shield
relation optimization. A later optimization needs exact CFG/SSA,
Profiling for Q-063 is complete for these paths. The
[first optimization](control-depth-performance-audit.md#first-optimization-loop-exit-reference-index-2026-10-14)
indexes loop-exit references at instruction emission rather than repeatedly
scanning the whole function. Paired CPU-pinned Debug lowering at 512 levels
improves while by 3.22×, loop by 1.85× and mutable while by 1.80×, with exact
public check/lower and runtime/fuel compatibility. That slice preserved the
legacy reference policy; Q-064 now records its separate correction with
explicit CFG incoming edges.
The [second optimization](control-depth-performance-audit.md#second-optimization-negative-after-query-reuse-2026-10-14)
reuses one completed negative subtree After query while walking enclosing Rest
frames, with AST identity/name/construct guards. Paired Debug mutable-match
lowering at 512 levels falls from 30.982 to 0.635 seconds (48.77×), with 341 unit
tests, 1,799 conformance cases and exact source/AIR/runtime comparisons. This
preserves first-use kills, sibling exclusion and loop reads; it is not a global
variable-liveness cache. Remaining assignment/read/positive-query costs and a
separately reviewed shield relation optimization remain open. A later
optimization needs exact CFG/SSA,
diagnostic-order, host-OOM and runtime/fuel compatibility checks.
No source-depth limit, new diagnostic, verifier rule, AIR instruction or
language semantic change is introduced by recording this limitation.
## Q-064 — Loop-exit reference search confuses function and block names
**Open; confirmed existing frontend diagnostic defect (2026-10-14).** While
**Closed; frontend diagnostic defect corrected (2026-10-14).** While
optimizing Q-063, a frozen pre-change Debug binary at `17cbe3e` accepts this
source in both `lower` and `check`, with exit 0:
@@ -692,9 +705,37 @@ mistakes `call @after_2()` for an incoming reference to that block. Its
first-substring test also allows an earlier non-reference substring in one
instruction to mask a later genuine reference in that same instruction.
The Q-063 reference-index optimization deliberately preserves this behavior;
it does not make the collision a language rule. Replacing the compatibility
index with actual CFG-edge metadata belongs to a separate correctness change,
with source/AIR, naming-collision, unreachable-code and diagnostic-priority
coverage. Evidence is in `/tmp/aji-q063-reaches/collision-*.aji` and the frozen
CLI's output. No native-stack failure or unsafe execution is established here.
The Q-063 reference-index optimization initially preserved this behavior;
it did not make the collision a language rule. The separate correctness fix
replaces that compatibility index with a per-block incoming-edge bit, updated
from explicit target indices only after a terminator is successfully emitted.
Every terminator declares its successors; `select` reuses its existing outcome
metadata. Calls and operand names cannot supply or mask a block edge. The bit
counts syntactic edges, including edges from disconnected blocks; this is not
entry-reachability analysis or constant folding. A host allocation failure
publishes neither the instruction nor its edges.
The other confirmed direction was a false rejection: in
`fn f(after_2: bool) -> u64`, `while after_2 { return 1u64; } return 42u64;`
previously reported E7006 at the reachable return. The operand's earlier
`after_2` substring masked the real exit target in the conditional branch.
This now accepts, returning 42 for `false` and 1 for `true`.
Qualification: 342 unit tests, 1,808 conformance cases (nine new), 182 targeted
CLI checks, plus the diagnostic-reason, independent-error, CFG-provenance and
hosted smoke suites. All 2,858 `check`/`lower` comparisons on 1,429 pre-existing
public sources and 240 runtime/fuel comparisons match the frozen pre-fix
executable exactly. Fourteen of the eighteen new fixture comparisons change
intentionally: five false acceptances reject E7006 `unreachable`, and two
false rejections accept; two valid break cases retain exact output. Diagnostic
priority, source/package positions, formatting, function-local state and host
OOM are covered. Incoming metadata is also checked against independently
parsed AIR successors for ten lowering programs. The frozen textual predicate
remains only in compatibility tests, with its collisions explicitly tested as
old defects.
The [control-depth audit](control-depth-performance-audit.md#correctness-follow-up-explicit-cfg-incoming-edges-q-064-2026-10-14)
records the implementation and evidence in
`/tmp/aji-q064-20261014-x_a6b4gb/`. Spec 15 §10 already requires the corrected
behavior: no new diagnostic, source rule, verifier rule, AIR meaning or runtime
instruction is introduced. Q-063's remaining performance work stays open.