cli: query field annotations iteratively and close type-depth audit

This commit is contained in:
dev committed 2026-10-10 15:46:46 +03:00
1 parent d98ddbc073
commit 46bd29953f
6 files changed
+291 -10

No files matched your search

+36 -1
View File
@@ -1,6 +1,6 @@
# AIR anonymous type-depth audit
Non-normative evidence for Q-059, initially at ba99ad6. This audit introduces no syntax-nesting limit, code, feature or acceptance rule. Parser repair preserves format-0 syntax and diagnostics; the verifier and other type traversals remain a separate open obligation.
Non-normative evidence for Q-059, initially at ba99ad6. This audit introduces no syntax-nesting limit, code, feature or acceptance rule. The sections below record successive failures and repairs; their remaining-work statements are historical. The [closing inventory](type-traversal-inventory.md) gives the final compiler type-traversal scope and bounds. Runtime validation remains separately tracked by Q-060.
## Reproducer and observations
@@ -204,3 +204,38 @@ The identity writer now emits prefixes through a type cursor and stores suffix l
Independent shallow comparisons cover scalar/nominal/generated names, capabilities, file modes, static functions, all wrappers, array lengths and prefixes around the exact byte boundary, including complete error objects and intermediate bytes. Writer-only deep fixtures produce an independently assembled 4,095-array key (16,382 bytes), reject the next array at its outer closing span (16,386 bytes), and reject a 32,768-array prefix at the original leaf checkpoint. These helper fixtures are not full source acceptance claims. Failed allocations check propagated OOM, prefix bytes and arena cleanup. Units/format checks and generic/static-function CLI integration (42/25 checks) pass; both new conformance regressions pin code E7006, and hosted checks pin implementation_limit/name/call-site provenance and identical check/lower/report/run/explore diagnostics.
Both previously failing growth sources now reach one E7006/implementation_limit at 2:35 without stderr; the one-array and single-64-array results retain their prior behavior. All 1,421 pre-existing public source checks and 506 accepted lowerings retain exact old/new exit/stdout/stderr. The full 1,791-case snapshot plus the two added focused regressions cover all 1,793 current conformance files exactly, with every case passing. Closing call-path inventory keeps Q-059 open; Q-056, Q-060 validation and Phase 6 gates remain separate. No normative/bundle/feature/code, runtime/effect/ownership or accepted-depth limit changes; no fresh Claude review is claimed.
## Best-effort field type lookup and closing inventory
The closing inspection finds native recursion in `typeOfNoFail`, called by
`peekType`/use inference. At d98ddbc, a shallow `r.x.len` expression over a
record's nested-array field accepts depth 4,096, but aborts at 16,384 and
65,536 with 10,001 typeOfNoFail frames, exit -6 and no diagnostic JSON.
Source arrays use `[T; N]`; the failing inputs are 65,662/262,270 bytes.
Only child core capture is disabled; no timeout ends a probe.
The query now validates the chain and resolves its leaf before allocating,
then constructs output with a fresh-node cursor. Its restricted name/array
classification, length rules and best-effort OOM-to-null behavior are unchanged.
Invalid/unknown leaves allocate nothing. Nodes are allocated outer-to-inner
instead of inner-to-outer; request counts, sizes and alignments match the old
query, and a partial private type is never returned. The caller arena owns
partial storage on failure. No verifier, runtime, ownership or syntax rule changes.
Independent shallow comparisons cover all recognized leaves, unsupported
constructors and valid/invalid nested lengths. A 65,536-node output is inspected
and freed iteratively; invalid deep leaves/lengths allocate nothing. Every one
of 64 node-allocation failures retains null, no diagnostic and complete cleanup.
Units/format checks and all 1,793 conformance files pass with exact coverage;
all 1,423 public source checks and 506 accepted lowerings retain byte-identical
old/new exit/stdout/stderr. Nominal CLI integration passes 130 checks, including
deep formatting/lowering, source/AIR checks, report parity and scalar execution.
The complete formerly aborting checks now accept without output. These tests
do not materialize a deeply nested runtime value.
The [production inventory](type-traversal-inventory.md) closes Q-059's compiler
type-traversal scope: loops/continuations cover unbounded type descent, and
remaining recursive type predicates retain their pre-existing fixed guards.
Expression/statement depth is a separate scope. Q-056 policy, Q-060's unfinished
full per-step GC validation and Phase 6 exit gates remain open. No accepted-depth
limit, normative/bundle/feature/code growth or fresh Claude review is claimed.
+8
View File
@@ -455,6 +455,8 @@ Compatibility impact is explicit: oversized values/frames formerly accepted now
## Q-059 — AIR type-syntax nesting and native recursion
**Resolved, 2026-10-10, for the compiler type-traversal scope in the [closing inventory](type-traversal-inventory.md).** The final inspection found another unguarded type walk: `typeOfNoFail`, reached by shallow `r.x.len` expressions with deep field annotations. At d98ddbc, 16,384/65,536 levels abort with 10,001 query frames and no diagnostic JSON; the iterative repair accepts both. All production paths in the inventory now use loops/continuations or their unchanged fixed-depth guards. Units, format checks, all 1,793 conformance files with exact coverage and deep source/AIR CLI integration pass. This adds no syntax-depth limit or semantic rule. Expression/statement recursion, fabricated cyclic host pointers and Q-060's runtime validation are outside this resolution. The following paragraphs retain the historical investigation states.
Source inspection during Q-058 finds recursive `parseType` in `src/air/parse.zig` without an explicit syntax-nesting bound. Size/property traversals also use native recursion over finite anonymous type syntax. **Unverified:** no parser stack-exhaustion reproducer has been run; syntactic finiteness alone does not establish a bound on native stack use.
2026-10-09 [executed audit](air-type-depth-audit.md): a 36,971-byte input with 4,096 length-one nested arrays aborts with a traceback containing thousands of parseType/parseCompoundType frames, rather than a diagnostic. The iterative parser repair accepts that input and unit-tests 32,768 levels, preserving old/new output on 364 public AIR files and constructor/error probes. A subsequent 16,384-depth check still aborts in verifier sizeQuery/sizeValue; that remaining failure is now verified. The original unverified note describes the state before these probes. No syntax-depth acceptance limit is introduced; Q-059 remains open for size, property, validity, equality and formatting traversal audits.
@@ -512,3 +514,9 @@ The [runtime value-size increment](runtime-value-depth-audit.md#runtime-value-si
The [runtime value JSON increment](runtime-value-depth-audit.md#runtime-value-json-repair) removes recursive value serialization and bypasses the outer stringify's fixed nesting table for internal payloads. Exact encoding/options, outer-container state, writer/allocation failure and deep returned-payload lifetimes are tested; the formerly failing CLI now emits a complete record in deterministic and hosted profiles. All five confirmed Q-060 failure paths have repairs, without a new limit or trap. Q-060 remains open for closing call-path checks, including the inspection-only cache-free public verification/runtime entry path and its connection to Q-059's uncached nominal queries; no verified failure on that path is claimed yet.
The [cache-free runtime increment](runtime-value-depth-audit.md#cache-free-runtime-size-query-path) removes the recursive accounted-size fallback available through public verification/runtime entry. All runtime size callers propagate temporary metadata OOM before authority charging, retaining quota, fuel and ownership behavior. The deep query-only failure is independently reproduced and repaired; verified library entry and cache equivalence are separately tested. Q-060 remains open for closing traversal checks and full per-step validation; no new normative limit, trap or diagnostic is introduced.
## Q-061 — Source expression/statement nesting and native recursion
Inspection during Q-059's closing inventory finds native recursion through source expression parsing (`binary`/`unary`), expression queries (`peekType`/`useIn`) and generic expression transformation (`expression`/`walk`). The fixed generic type/instantiation guards do not establish a bound on arbitrary expression or statement nesting. **Unverified:** no expression/statement stack-exhaustion probe has been run in this audit; this entry records inspection risk, not an observed failure or a new acceptance rule.
Audit these paths separately with finite public/generated source inputs before claiming whole-frontend bounded native-stack processing. Prefer explicit continuations preserving existing syntax, evaluation/query order, diagnostics and OOM behavior. A new depth rejection requires a normative decision; Q-059's type-traversal resolution does not authorize one.
+60
View File
@@ -0,0 +1,60 @@
# Compiler type-traversal inventory
Non-normative closing inventory for Q-059, at d98ddbc plus the companion
`typeOfNoFail` repair. The [executed audit](air-type-depth-audit.md) records
individual failures, compatibility comparisons and allocation tests.
Scope: finite parsed AIR/source type syntax, resolved nominal declaration
graphs, type diagnostics, canonical output and audit reports. Native stack
depth must not grow with anonymous type nesting or nominal graph depth on
these paths. This does not promise constant memory/time, bounded expression
or statement nesting, or bounded processing of fabricated cyclic host pointers.
| Production path | Traversal / remaining bound |
|---|---|
| AIR `parseType`, compound construction (`src/air/parse.zig`) | Pending constructor frames; no recursive child parse. |
| AIR `Type.eql`, `inner`, classification (`src/air/module.zig`) | Cursor comparison or one-node inspection; names stop at declaration identity. |
| Verifier `accountedSize`, `SizeMemo.size`, `ValueSizes.visit` (`src/verifier/budget.zig`) | Affine anonymous fold, explicit nominal continuations and inner-node loop; nominal cycle depth changes exactly as before. |
| `wellFormed`, `argumentLengths`, finite layouts (`src/verifier/types.zig`) | Anonymous cursors and nominal DFS frames; graph-owner stops and ordered diagnostics retained. |
| Nine structural properties, dependencies, height/witness summaries (`src/air/properties.zig`) | Anonymous cursor/mode transitions plus monotone nominal worklist; summary saturation at 65/34 is unchanged. |
| Public uncached property queries | Temporary prepared module, allocator/error API; no recursive raw fallback. Prepare once for repeated nominal queries to avoid repeated whole-module preparation. |
| `bounded` (`src/air/properties.zig`) | Remaining production recursion checks `depth >= 64` before descent; cached nominal reads use height. |
| AIR canonical/diagnostic type printer, report capability collector (`src/air/print.zig`, `src/report.zig`) | Explicit suffix stack or anonymous cursor; declaration roots enumerated separately. |
| Source `typeExpr` (`src/frontend/parse.zig`) | Explicit constructors/argument continuations, including speculative advice parsing. |
| Source formatter, generic-use detector (`src/frontend/format.zig`, `src/frontend/generics.zig`) | Token spans / AST work entries; reflective visitation queues children rather than recursively visiting type syntax. |
| Source type-position and Copy-content scans (`src/frontend/type_positions.zig`, `src/frontend/type_properties.zig`) | Anonymous cursors, explicit nominal argument/member continuations and indexed cycle paths. |
| Source resolution, text, AIR conversion, equality (`src/frontend/lower.zig`) | Pending constructors/suffixes, fresh output-target cursor or two comparison cursors. |
| Source linearity, signature feature discovery, SSA zero | Iterative chains; the existing module-sized feature-discovery guard remains. Unsupported zero leaves reject before emission. |
| Source best-effort `typeOfNoFail` | Validate chain/leaf before allocation, then build fresh output nodes iteratively. Only names/arrays are recognized; OOM remains `null`, without a diagnostic or published partial type. |
| Source `forbiddenIn` | Remaining recursion checks `depth > 32` before descent; named cached distance prunes unreachable witnesses. Calls to annotation resolution use the iterative path above. |
| Generic headers/substitution/static arguments | `headerType`/`headerArgument` and `ty`/`instantiate` retain their existing guards at 64. Static-function argument resolution re-enters guarded instantiation; reflective specialization intercepts `ast.Type` before visiting its representation. |
| Composed specialization identities | Iterative prefix/leaf/suffix writer. Substitution can return an already composed type deeper than one guarded `ty` traversal, so identity emission must not rely on that guard. Existing key-size checks retain their postorder spans. |
Prepared reads have an explicit precondition. `verifyModule` discards caller
caches; `types.check` prepares its module before type queries and subsequent
borrow/init/bounds stages. Source lowering uses its separately prepared
`property_module`. Raw public APIs prepare temporary facts rather than silently
using the prepared-only API. Replacing declarations invalidates both caches.
The recursive `Reference*` derivations, `referenceSize`, `referenceTypeHint`
and AIR-property `witness` are shallow test oracles, not production call paths.
A textual self-call census was used as a search aid, followed by inspection of
delegated and mutually recursive paths; it is not itself a proof. The module
import graph has a separate existing depth-256 guard and does not traverse
type syntax. Recursive expression parsing, expression queries and generic
expression transformation remain outside this type-depth claim and are logged
separately as inspection-only Q-061.
Validation combines the increment-specific independent shallow oracles,
32,768/65,536-level helper and CLI probes, nominal cycles/shared graphs,
allocation failures and exact diagnostic/canonical-output comparisons. The
latest field-expression probe is deliberately shallow (`r.x.len`) with a deep
annotation: it catches a type walk missed by plain parameter checks. Its CLI
integration also checks formatting, source/AIR checking, lowering, report parity
and scalar execution. It does not materialize a deep runtime value.
Q-060 separately tracks runtime value/copy/collector/JSON traversal and its
unfinished full collection-before-each-instruction validation. Neither this
inventory nor the compiler tests close that runtime gate or the Phase 6 exit
review. Claude's earlier review covers uncached nominal properties only;
subsequent frontend repairs have prepared review requests, not a received review.
+6
View File
@@ -508,3 +508,9 @@ The [Q-059 zero increment](../design/air-type-depth-audit.md#source-ssa-zero-emi
The [Q-059 identity increment](../design/air-type-depth-audit.md#composed-specialization-identity) repairs native failures on tiny expanding-substitution sources. Key emission is iterative; canonical bytes, postorder size/error-span checks, reuse/names and all existing specialization limits remain unchanged. Two permanent conformance cases and hosted CLI checks retain one E7006/implementation_limit at the call site across all rejection entry points.
Units/format checks, shallow/deep key-boundary and OOM tests, generic/static-function integration (42/25), and old/new checks/lowerings over the pre-existing source corpus (1,421/506) pass. The full 1,791-case snapshot plus the two focused additions cover all 1,793 current conformance files exactly. Closing call-path inventory, Q-056 policy, Q-060 validation and Phase 6 gates remain open. No normative/bundle/feature/code or accepted-depth limit changes; no fresh Claude review is claimed.
## Type-depth closing audit (2026-10-10)
Q-059 is resolved for the [compiler type-traversal inventory](../design/type-traversal-inventory.md). The final repair removes a confirmed `typeOfNoFail` failure reached through shallow field expressions; complete checks accept 16,384/65,536 nested field-array levels. The best-effort query retains its type classification and OOM-to-null contract without publishing partial output. Independent shallow/deep/allocation tests, units/format checks, all 1,793 conformance cases with exact coverage, nominal CLI integration (130 checks) and byte-identical old/new source checks/lowerings (1,423/506) pass.
This closes type descent, not arbitrary expression/statement recursion (inspection-only Q-061), Q-056 policy, Q-060's unfinished full per-step GC validation or Phase 6 exit review. No normative/bundle/feature/code or acceptance-limit changes; Claude's earlier nominal-property review does not cover these later frontend increments.
+158 -9
View File
@@ -1702,17 +1702,35 @@ const Lowerer = struct {
};
}
fn typeOfNoFail(l: *Lowerer, t: ast.Type) ?Ty {
return switch (t.kind) {
fn typeOfNoFail(l: *Lowerer, annotation: ast.Type) ?Ty {
// Validate before allocating, as the old postorder query did. This
// best-effort lookup recognizes only names and fixed array chains.
var t = annotation;
while (t.kind == .array) {
const a = t.kind.array;
if (a.len == 0 or a.len > (@as(u64, 1) << 32)) return null;
t = a.elem.*;
}
const known: ?Ty = switch (t.kind) {
.name => |n| if (isIntName(n)) Ty{ .int = n } else if (std.mem.eql(u8, n, "bool")) .bool else if (std.meta.stringToEnum(authority.Builtin, n)) |b| Ty{ .builtin = b } else l.enumOrStruct(n, t.span),
.array => |a| blk: {
if (a.len == 0 or a.len > (@as(u64, 1) << 32)) break :blk null;
const elem = l.typeOfNoFail(a.elem.*) orelse break :blk null;
if (elem == .void or elem == .never) break :blk null;
break :blk l.arrayOf(elem, a.len) catch null;
},
else => null,
};
const leaf = known orelse return null;
var result: Ty = undefined;
var target = &result;
t = annotation;
while (t.kind == .array) {
const a = t.kind.array;
// Only fresh output nodes are writable; no source AST is borrowed
// or changed. The caller arena retains partial nodes on OOM.
const node = l.arena.create(Ty.Arr) catch return null;
node.len = a.len;
target.* = .{ .array = node };
target = &node.elem;
t = a.elem.*;
}
target.* = leaf;
return result;
}
fn enumOrStruct(l: *Lowerer, name: []const u8, span: Span) ?Ty {
@@ -4881,7 +4899,7 @@ const AirConversionAllocations = struct {
return null;
}
fn free(_: *anyopaque, _: []u8, _: std.mem.Alignment, _: usize) void {
unreachable; // Conversion transfers nodes to the caller, never frees them.
unreachable; // Type construction transfers nodes to the caller.
}
fn deinit(self: *@This()) void {
for (self.nodes[0..self.count]) |node| if (node.pointer) |ptr| self.backing.rawFree(ptr[0..node.length], node.alignment, @returnAddress());
@@ -4889,6 +4907,137 @@ const AirConversionAllocations = struct {
}
};
// Independent pre-repair best-effort lookup, only for shallow test trees.
fn referenceTypeHint(l: *Lowerer, t: ast.Type) ?Ty {
return switch (t.kind) {
.name => |n| if (isIntName(n)) Ty{ .int = n } else if (std.mem.eql(u8, n, "bool")) .bool else if (std.meta.stringToEnum(authority.Builtin, n)) |b| Ty{ .builtin = b } else l.enumOrStruct(n, t.span),
.array => |a| blk: {
if (a.len == 0 or a.len > (@as(u64, 1) << 32)) break :blk null;
const elem = referenceTypeHint(l, a.elem.*) orelse break :blk null;
if (elem == .void or elem == .never) break :blk null;
break :blk l.arrayOf(elem, a.len) catch null;
},
else => null,
};
}
fn expectTypeHintMatches(l: *Lowerer, t: ast.Type) !void {
const before = referenceTypeHint(l, t);
const after = l.typeOfNoFail(t);
try std.testing.expectEqual(before == null, after == null);
if (before) |b| try std.testing.expect(b.eql(after.?));
try std.testing.expect(l.problem == null and l.unimpl == null);
}
test "best-effort source type lookup matches the shallow independent query" {
var scratch: std.heap.ArenaAllocator = .init(std.testing.allocator);
defer scratch.deinit();
const a = scratch.allocator();
const m = (try parse_mod.parse(a, "module hints\nstruct S { x: u8 }\nenum E { Some, None }\nfn main() -> void effects [] {}\n")).ok;
var l: Lowerer = .{ .arena = a, .m = m };
var leaves: std.ArrayList(ast.Type) = .empty;
const span: Span = .{ .start = .{ .line = 2, .col = 7 }, .end = .{ .line = 2, .col = 8 } };
for (int_types ++ [_][]const u8{ "bool", "S", "E", "alloc_error", "cap_error", "io_error", "void", "never", "region", "stream", "listener", "missing", "f32", "f64" }) |name| {
try leaves.append(a, .{ .span = span, .kind = .{ .name = name } });
}
const u8_type: ast.Type = .{ .span = span, .kind = .{ .name = "u8" } };
const wrappers = comptime std.meta.fieldNames(Lowerer.TypeWrapper) ++ [_][]const u8{"unknown"};
for (wrappers) |wrapper| {
try leaves.append(a, .{ .span = span, .kind = .{ .wrapped = .{ .wrapper = wrapper, .inner = &u8_type } } });
}
try leaves.appendSlice(a, &.{
.{ .span = span, .kind = .{ .cap = "mem.alloc" } },
.{ .span = span, .kind = .{ .file = "read" } },
.{ .span = span, .kind = .{ .applied = .{ .name = "S", .args = &.{u8_type} } } },
.{ .span = span, .kind = .{ .function_ref = .{ .name = "main" } } },
});
const lengths = [_]u64{ 0, 1, 7, @as(u64, 1) << 32, (@as(u64, 1) << 32) + 1, std.math.maxInt(u64) };
for (leaves.items) |*leaf| {
try expectTypeHintMatches(&l, leaf.*);
for (lengths) |length| {
const inner: ast.Type = .{ .span = span, .kind = .{ .array = .{ .elem = leaf, .len = length } } };
try expectTypeHintMatches(&l, inner);
for (lengths) |outer_length| {
try expectTypeHintMatches(&l, .{ .span = span, .kind = .{ .array = .{ .elem = &inner, .len = outer_length } } });
}
}
}
}
test "deep best-effort source type lookup owns output and rejects without allocation" {
var scratch: std.heap.ArenaAllocator = .init(std.testing.allocator);
defer scratch.deinit();
const a = scratch.allocator();
const m: ast.Module = .{ .name = "hints", .types = &.{}, .functions = &.{} };
const count = 65_536;
const nodes = try a.alloc(ast.Type, count + 1);
const span: Span = .{ .start = .{ .line = 1, .col = 1 }, .end = .{ .line = 1, .col = 2 } };
nodes[0] = .{ .span = span, .kind = .{ .name = "u8" } };
for (nodes[1..], 1..) |*node, i| node.* = .{ .span = span, .kind = .{ .array = .{ .elem = &nodes[i - 1], .len = i } } };
var allocations: std.testing.FailingAllocator = .init(std.testing.allocator, .{});
var l: Lowerer = .{ .arena = allocations.allocator(), .m = m };
var current = l.typeOfNoFail(nodes[count]).?;
var remaining: usize = count;
while (remaining != 0) : (remaining -= 1) {
try std.testing.expect(current == .array);
const node = current.array;
try std.testing.expectEqual(@as(u64, remaining), node.len);
current = node.elem;
// Only tests individually free nodes; production owns a caller arena.
allocations.allocator().destroy(node);
}
try std.testing.expectEqualStrings("u8", current.int);
try std.testing.expectEqual(@as(usize, count), allocations.allocations);
try std.testing.expectEqual(allocations.allocated_bytes, allocations.freed_bytes);
var no_alloc: std.testing.FailingAllocator = .init(std.testing.allocator, .{ .fail_index = 0 });
var invalid: Lowerer = .{ .arena = no_alloc.allocator(), .m = m };
for ([_][]const u8{ "missing", "void", "never" }) |name| {
nodes[0].kind = .{ .name = name };
try std.testing.expect(invalid.typeOfNoFail(nodes[count]) == null);
}
nodes[0].kind = .{ .name = "u8" };
nodes[1].kind.array.len = 0;
try std.testing.expect(invalid.typeOfNoFail(nodes[count]) == null);
nodes[1].kind.array.len = (@as(u64, 1) << 32) + 1;
try std.testing.expect(invalid.typeOfNoFail(nodes[count]) == null);
try std.testing.expect(!no_alloc.has_induced_failure);
try std.testing.expect(invalid.problem == null and invalid.unimpl == null);
}
test "best-effort source type lookup preserves null on every allocation failure" {
var scratch: std.heap.ArenaAllocator = .init(std.testing.allocator);
defer scratch.deinit();
const a = scratch.allocator();
const m: ast.Module = .{ .name = "hints", .types = &.{}, .functions = &.{} };
const nodes = try a.alloc(ast.Type, 65);
const span: Span = .{ .start = .{ .line = 1, .col = 1 }, .end = .{ .line = 1, .col = 2 } };
nodes[0] = .{ .span = span, .kind = .{ .name = "u8" } };
for (nodes[1..], 1..) |*node, i| node.* = .{ .span = span, .kind = .{ .array = .{ .elem = &nodes[i - 1], .len = i } } };
for (0..65) |fail_index| {
var before_fail: std.testing.FailingAllocator = .init(std.testing.allocator, .{ .fail_index = fail_index });
var after_fail: std.testing.FailingAllocator = .init(std.testing.allocator, .{ .fail_index = fail_index });
var before_nodes: AirConversionAllocations = .{ .backing = before_fail.allocator() };
var after_nodes: AirConversionAllocations = .{ .backing = after_fail.allocator() };
var before: Lowerer = .{ .arena = before_nodes.allocator(), .m = m };
var after: Lowerer = .{ .arena = after_nodes.allocator(), .m = m };
const original = referenceTypeHint(&before, nodes[64]);
const current = after.typeOfNoFail(nodes[64]);
try std.testing.expectEqual(original == null, current == null);
try std.testing.expectEqual(fail_index < 64, current == null);
if (original) |ty| try std.testing.expect(ty.eql(current.?));
try std.testing.expectEqual(before_nodes.count, after_nodes.count);
for (before_nodes.nodes[0..before_nodes.count], after_nodes.nodes[0..after_nodes.count]) |old, new| {
try std.testing.expectEqual(old.length, new.length);
try std.testing.expectEqual(old.alignment, new.alignment);
}
try std.testing.expect(after.problem == null and after.unimpl == null);
before_nodes.deinit();
after_nodes.deinit();
try std.testing.expectEqual(before_fail.allocated_bytes, before_fail.freed_bytes);
try std.testing.expectEqual(after_fail.allocated_bytes, after_fail.freed_bytes);
}
}
// Independent pre-repair comparison, restricted to shallow test trees.
fn referenceSourceEquality(a: Ty, b: Ty) bool {
if (std.meta.activeTag(a) != std.meta.activeTag(b)) return false;
+23
View File
@@ -85,4 +85,27 @@ with tempfile.TemporaryDirectory(prefix='aji-nominal-queries-') as directory:
assert (record['code'], record['file'], record['line']) == ('E1003', 'nodes.aji', 2), record
assert record['type'].endswith('N0'), record
# A shallow field expression must not recursively walk its deep annotation
# in the best-effort type query used by `.len`. Main executes only a scalar;
# these probes exercise compiler paths, not materialization of deep values.
for depth in (16384, 65536):
annotation = '[' * depth + 'u8' + ';1]' * depth
source = root / f'field-type-{depth}.aji'
source.write_text('module field.types\nstruct Record { x: ' + annotation + ' }\n'
'fn size(r: Record) -> usize effects [] { r.x.len }\n'
'fn main() -> u64 effects [] { 42u64 }\n')
cli('check', source)
lowered = cli('lower', source)
assert 'const.usize 1' in lowered, lowered[-200:]
raw = root / f'field-type-{depth}.air'
raw.write_text(lowered)
cli('check', raw)
formatted = root / f'field-type-{depth}-formatted.aji'
formatted.write_text(cli('fmt', source))
cli('fmt', '--check', formatted)
assert cli('lower', formatted) == lowered
assert json.loads(cli('run', '--fuel', '100', source))['value'] == 42
assert json.loads(cli('run', '--fuel', '100', raw))['value'] == 42
assert json.loads(cli('report', source)) == json.loads(cli('report', raw))
print(f'nominal query CLI integration passed ({checks} checks)')