air: compare and print nested types without recursion

This commit is contained in:
dev committed 2026-10-09 20:09:00 +03:00
1 parent d0fcc3d473
commit 53030efcea
7 files changed
+180 -67

No files matched your search

+10
View File
@@ -70,3 +70,13 @@ Unit tests cover 32,768 anonymous arrays ending in plain data, task-local state
The original complete check now accepts depths 4,096, 16,384 and 32,768 on the ordinary 8-MiB stack, with no diagnostic output. A separate 16,384-depth return-equality check accepts, and an invalid atomic content type at the same depth returns E1001 with the complete found type rather than aborting. These observations do not prove arbitrary-depth equality/formatting or uncached nominal traversal. Q-059 remains open; no semantic feature, public diagnostic code, bundle growth or new acceptance limit is introduced.
Further probes confirm the remaining sites rather than merely inferring them from source: return equality accepts depth 32,768 but aborts at 65,536 with 10,001 Type.eql frames; invalid atomic content aborts at depth 32,768 with 9,999 printType frames. Both failing checks exit -6 without diagnostic JSON. Core capture is disabled only for the child; no timeout ends a probe. Equality and diagnostic/canonical type printing now have independently verified native-stack failures.
## Type equality and printing repair
Type.eql now compares anonymous chains iteratively without allocation. Tags still differ before descent; every array length is checked before its element, and named types compare declaration indices without expanding the nominal graph. All constructor and leaf identities are unchanged.
Type printing now records anonymous suffixes in an explicit stack, then emits them from the innermost outward. Array suffixes retain their original lengths and canonical comma/space spelling; other wrappers close with >. Named declarations remain names. The internal Zig print/printType API receives a compiler allocator explicitly, with updated verifier/serializer callers; allocation and writer errors propagate. Stack storage is proportional to input nesting, deallocated after the print attempt, and adds no heap allocation to an Aji program. AIR text, diagnostic fields/codes and JSON serialization rules do not change.
Unit tests compare separate 65,536-level chains with equal types, unequal deep leaves and unequal middle array lengths; they retain each unary constructor identity. A 65,536-level varied-length type prints exactly and passes parse/print/parse/print canonical equality. Wrapper spellings, suffix-allocation failure and buffered writer failure are checked independently. Unit/format checks, test-extended and all 1,769 conformance cases pass, and all 366 public AIR checks retain exact old/new exit status, stdout and stderr.
Both verified crashing CLI inputs now finish: return equality at depth 65,536 accepts with no output, and invalid atomic content at depth 32,768 returns exactly one E1001 at the original primary position with the complete canonical found type. These are direct process outcomes on the ordinary native stack, not just isolated helper tests. Uncached nominal fallback and other type-query call paths still require audit; Q-059 remains open. No new syntax-depth limit, semantic feature, public diagnostic code or bundle text is introduced.
+2
View File
@@ -466,3 +466,5 @@ The [size-query increment](air-type-depth-audit.md#size-query-repair) removes re
The [type-validity increment](air-type-depth-audit.md#type-validity-and-finite-layout-repair) iterates anonymous position/length checks and finite-layout DFS, preserving graph stops, wrapper gates and ordered cycle diagnostics. Deep unit cases cover 32,768 anonymous and nominal levels. Complete checking at 16,384 now passes wellFormed and aborts in Module.isLinearType; property, equality, formatting and uncached nominal queries remain open. No new depth limit or normative rule is introduced.
The [anonymous property-query increment](air-type-depth-audit.md#anonymous-property-query-repair) removes recursive anonymous linearity/property/dependency walks, preserving Send/Share mode changes, nominal fixed points and the existing saturated height/witness summaries. Complete checking now accepts 32,768 nested arrays. Follow-up checks verify separate remaining failures: Type.eql at depth 65,536 and diagnostic printType at depth 32,768, both without diagnostic JSON. Equality/printing and uncached nominal fallback remain open; Q-059 is not resolved.
The [equality/printing increment](air-type-depth-audit.md#type-equality-and-printing-repair) removes anonymous recursion from Type.eql and diagnostic/canonical printing. The formerly failing 65,536-depth equality check now accepts; the 32,768-depth invalid-atomic check returns one E1001 with the complete found type. The serializer uses an explicit compiler allocator for its suffix stack, retaining AIR spelling and diagnostic fields. Uncached nominal fallback and remaining type-query call paths still need audit; Q-059 remains open.
+2
View File
@@ -347,6 +347,8 @@ The [Q-059 type-validity increment](../design/air-type-depth-audit.md#type-valid
The [Q-059 anonymous property-query increment](../design/air-type-depth-audit.md#anonymous-property-query-repair) iterates linearity, structural predicates and dependency discovery, with explicit Send/Share transitions and unchanged saturated height/witness summaries. Unit cases cover 32,768 anonymous levels and phantom dependencies, 65,536 alternating ref/mutex edges, and saturation boundaries. Unit/format checks, test-extended, all 1,769 conformance cases and exact old/new comparisons on 366 public AIR files pass. Complete checking accepts 32,768 nested arrays; separate probes now verify failures in Type.eql at 65,536 and diagnostic printType at 32,768. Q-059 and Phase 6 remain open. No normative/bundle/feature/code change or new syntax-depth limit; no fresh Claude review was available.
The [Q-059 equality/printing increment](../design/air-type-depth-audit.md#type-equality-and-printing-repair) iterates structural type comparison and emits canonical suffixes through an explicitly allocated compiler stack. Constructor/leaf identities, array lengths, AIR spelling and diagnostic payloads remain unchanged. Deep unit cases cover equality/inequality and varied-length canonical round trips at 65,536 levels, plus allocation/writer errors. Unit/format checks, test-extended, all 1,769 conformance cases and exact old/new output comparisons on 366 public AIR files pass. The previous CLI failures now finish: equality at 65,536 accepts; invalid atomic content at 32,768 returns one E1001 with its complete found type. Q-059 remains open for uncached nominal/query call-path audits, with no normative/bundle/feature/code change or new depth limit. No fresh Claude review was available.
Spec 15's initial Phase 6A limits now point to its existing extensions. Its introductory diagnostic rule follows §10 and construct-specific codes; widening reports source E7005 while AIR retains E1002, including the corrected Quick Reference entry. Multi-result bindings include complete unpacking, byte escapes agree with the later exact list, and grammar comments locate graph access in §8. Old incremental limits link buffers/borrow returns to §17/§19. No grammar production, semantic rule or implementation changes. Six existing public fixtures confirm the reported code and deterministic successful AIR; Claude independently audited the corrections. The reference bundle rebuilds; source growth is +50/+47/+58 tokens across the three tokenizers, with unchanged Quick Reference token counts, AIR and std (docs/agent/README.md). P6-1/P6-5 remain open for their unimplemented surfaces.
## P6-6 contract spec gate (2026-10-09)
+60 -13
View File
@@ -105,19 +105,29 @@ pub const Type = union(enum) {
pub const Array = struct { elem: Type, len: u64 };
pub fn eql(a: Type, b: Type) bool {
if (std.meta.activeTag(a) != std.meta.activeTag(b)) return false;
return switch (a) {
.int => |x| b.int == x,
.named => |x| b.named == x,
.local, .ref, .mut, .slice, .slice_mut, .own, .own_array, .buffer, .task, .sender, .receiver, .mutex, .guard, .island, .frozen, .arc, .iref, .atomic => |x| x.eql(b.inner().?),
.region, .scope, .shield => true,
.array => |x| x.len == b.array.len and x.elem.eql(b.array.elem),
.cap => |k| b.cap == k,
.builtin => |e| b.builtin == e,
.resource => |r| b.resource == r,
.bool, .void, .never => true,
};
pub fn eql(initial_a: Type, initial_b: Type) bool {
var a = initial_a;
var b = initial_b;
while (true) {
if (std.meta.activeTag(a) != std.meta.activeTag(b)) return false;
switch (a) {
.int => |x| return b.int == x,
.named => |x| return b.named == x,
.local, .ref, .mut, .slice, .slice_mut, .own, .own_array, .buffer, .task, .sender, .receiver, .mutex, .guard, .island, .frozen, .arc, .iref, .atomic => |x| {
a = x.*;
b = b.inner().?;
},
.array => |x| {
if (x.len != b.array.len) return false;
a = x.elem;
b = b.array.elem;
},
.cap => |k| return b.cap == k,
.builtin => |e| return b.builtin == e,
.resource => |r| return b.resource == r,
.region, .scope, .shield, .bool, .void, .never => return true,
}
}
}
/// Element or pointee type of storage, borrow and slice types.
@@ -836,3 +846,40 @@ test "IntType host types" {
try std.testing.expect(IntType.Zig(.usize) == u64);
try std.testing.expectEqual(@as(u8, 128), IntType.u128.bits());
}
test "deep structural type equality checks inner tags and every array length" {
var scratch = std.heap.ArenaAllocator.init(std.testing.allocator);
defer scratch.deinit();
const a = scratch.allocator();
const left = try a.alloc(Type.Array, 65_536);
const right = try a.alloc(Type.Array, left.len);
var x: Type = .{ .int = .u8 };
var y = x;
for (left, right, 0..) |*l, *r, i| {
l.* = .{ .elem = x, .len = i + 1 };
r.* = .{ .elem = y, .len = i + 1 };
x = .{ .array = l };
y = .{ .array = r };
}
try std.testing.expect(x.eql(y) and y.eql(x));
right[0].elem = .bool;
try std.testing.expect(!x.eql(y) and !y.eql(x));
right[0].elem = .{ .int = .u8 };
right[32_768].len += 1;
try std.testing.expect(!x.eql(y) and !y.eql(x));
right[32_768].len -= 1;
try std.testing.expect(x.eql(y));
try std.testing.expect(!x.eql(.{ .ref = &y }));
}
test "structural equality preserves each unary constructor identity" {
const x: Type = .{ .named = 0 };
const y: Type = .{ .named = 1 };
inline for (.{ .local, .ref, .mut, .slice, .slice_mut, .own, .own_array, .buffer, .task, .sender, .receiver, .mutex, .guard, .island, .frozen, .arc, .iref, .atomic }) |tag| {
const left: Type = @unionInit(Type, @tagName(tag), &x);
const equal: Type = @unionInit(Type, @tagName(tag), &x);
const different: Type = @unionInit(Type, @tagName(tag), &y);
try std.testing.expect(left.eql(equal));
try std.testing.expect(!left.eql(different) and !left.eql(x));
}
}
+104 -52
View File
@@ -4,8 +4,9 @@ const std = @import("std");
const air = @import("module.zig");
const Writer = std.Io.Writer;
const PrintError = std.mem.Allocator.Error || Writer.Error;
pub fn print(m: air.Module, w: *Writer) Writer.Error!void {
pub fn print(allocator: std.mem.Allocator, m: air.Module, w: *Writer) PrintError!void {
try w.print("module {s}\nair {d}\nlang {d}.{d}\nfeatures [", .{ m.name, m.format_version, m.lang[0], m.lang[1] });
try list(w, m.features);
try w.writeAll("]\n");
@@ -19,7 +20,7 @@ pub fn print(m: air.Module, w: *Writer) Writer.Error!void {
for (fields, 0..) |f, i| {
try w.writeAll(if (i == 0) " " else ", ");
try w.print("{s}: ", .{f.name});
try printType(m, f.ty, w);
try printType(allocator, m, f.ty, w);
}
try w.writeAll(if (fields.len == 0) "}\n" else " }\n");
},
@@ -32,7 +33,7 @@ pub fn print(m: air.Module, w: *Writer) Writer.Error!void {
try w.writeByte('(');
for (v.payload, 0..) |t, j| {
if (j != 0) try w.writeAll(", ");
try printType(m, t, w);
try printType(allocator, m, t, w);
}
try w.writeByte(')');
}
@@ -44,9 +45,9 @@ pub fn print(m: air.Module, w: *Writer) Writer.Error!void {
for (m.functions) |f| {
try w.print("\nfn @{s}(", .{f.name});
try params(m, f, f.params, w);
try params(allocator, m, f, f.params, w);
try w.writeAll(") -> ");
try printType(m, f.ret, w);
try printType(allocator, m, f.ret, w);
if (f.ret_from) |i| try w.print(" from %{s}", .{f.values[f.params[i].value].name});
try w.writeAll("\neffects [");
try list(w, f.effects);
@@ -65,7 +66,7 @@ pub fn print(m: air.Module, w: *Writer) Writer.Error!void {
try w.writeAll(b.name);
if (b.params.len != 0) {
try w.writeByte('(');
try params(m, f, b.params, w);
try params(allocator, m, f, b.params, w);
try w.writeByte(')');
}
try w.writeAll(":\n");
@@ -76,7 +77,7 @@ pub fn print(m: air.Module, w: *Writer) Writer.Error!void {
if (inst.result2) |r2| try w.print(", %{s}", .{f.values[r2].name});
try w.writeAll(" = ");
}
try printOp(m, f, inst.op, w);
try printOp(allocator, m, f, inst.op, w);
try w.writeByte('\n');
}
}
@@ -90,46 +91,49 @@ fn list(w: *Writer, items: []const []const u8) Writer.Error!void {
}
}
fn params(m: air.Module, f: air.Function, ps: []const air.Param, w: *Writer) Writer.Error!void {
fn params(allocator: std.mem.Allocator, m: air.Module, f: air.Function, ps: []const air.Param, w: *Writer) PrintError!void {
for (ps, 0..) |p, i| {
if (i != 0) try w.writeAll(", ");
try w.print("%{s}: ", .{f.values[p.value].name});
try printType(m, p.ty, w);
try printType(allocator, m, p.ty, w);
}
}
pub fn printType(m: air.Module, t: air.Type, w: *Writer) Writer.Error!void {
switch (t) {
.int => |it| try w.writeAll(@tagName(it)),
.named => |i| try w.print("@{s}", .{m.types[i].name}),
.local, .ref, .mut, .slice, .slice_mut => |inner| {
try w.print("{s}<", .{@tagName(t)});
try printType(m, inner.*, w);
try w.writeByte('>');
},
.array => |a| {
try w.writeAll("array<");
try printType(m, a.elem, w);
try w.print(", {d}>", .{a.len});
},
.cap => |k| try w.print("cap<{s}>", .{air.authority.kinds[k].name}),
.builtin => |b| try w.writeAll(@tagName(b)),
.resource => |r| try w.writeAll(r.text()),
.own, .own_array, .buffer => |inner| {
try w.print("{s}<", .{@tagName(t)});
try printType(m, inner.*, w);
try w.writeByte('>');
},
.region => try w.writeAll("region"),
.scope => try w.writeAll("scope"),
.task, .sender, .receiver, .mutex, .guard, .island, .frozen, .arc, .iref, .atomic => |inner| {
try w.print("{s}<", .{@tagName(t)});
try printType(m, inner.*, w);
try w.writeByte('>');
},
.shield => try w.writeAll("shield"),
.bool, .void, .never => try w.writeAll(@tagName(t)),
/// The allocator belongs to the compiler/serializer, never to an Aji program.
/// Save suffixes explicitly so arbitrary finite anonymous nesting does not
/// consume native stack. Named declarations remain names, not expanded graphs.
pub fn printType(allocator: std.mem.Allocator, m: air.Module, initial: air.Type, w: *Writer) PrintError!void {
const Suffix = union(enum) { close, array: u64 };
var pending: std.ArrayList(Suffix) = .empty;
defer pending.deinit(allocator);
var t = initial;
while (true) {
switch (t) {
.array => |row| {
try w.writeAll("array<");
try pending.append(allocator, .{ .array = row.len });
t = row.elem;
continue;
},
.local, .ref, .mut, .slice, .slice_mut, .own, .own_array, .buffer, .task, .sender, .receiver, .mutex, .guard, .island, .frozen, .arc, .iref, .atomic => |inner| {
try w.print("{s}<", .{@tagName(t)});
try pending.append(allocator, .close);
t = inner.*;
continue;
},
.int => |it| try w.writeAll(@tagName(it)),
.named => |i| try w.print("@{s}", .{m.types[i].name}),
.cap => |k| try w.print("cap<{s}>", .{air.authority.kinds[k].name}),
.builtin => |b| try w.writeAll(@tagName(b)),
.resource => |r| try w.writeAll(r.text()),
.region, .scope, .shield, .bool, .void, .never => try w.writeAll(@tagName(t)),
}
break;
}
while (pending.pop()) |suffix| switch (suffix) {
.close => try w.writeByte('>'),
.array => |len| try w.print(", {d}>", .{len}),
};
}
fn scalarName(t: air.Type) []const u8 {
@@ -169,7 +173,7 @@ pub fn literal(it: air.IntType, bits: u128, w: *Writer) Writer.Error!void {
}
}
fn printOp(m: air.Module, f: air.Function, op: air.Op, w: *Writer) Writer.Error!void {
fn printOp(allocator: std.mem.Allocator, m: air.Module, f: air.Function, op: air.Op, w: *Writer) PrintError!void {
switch (op) {
.@"const" => |c| switch (c.ty) {
.bool => try w.print("const.bool {s}", .{if (c.bits != 0) "true" else "false"}),
@@ -212,12 +216,12 @@ fn printOp(m: air.Module, f: air.Function, op: air.Op, w: *Writer) Writer.Error!
},
.array_make => |x| {
try w.writeAll("array.make ");
try printType(m, x.ty, w);
try printType(allocator, m, x.ty, w);
try values(f, x.args, w);
},
.aggregate_unpack => |x| {
try w.writeAll(if (x.ty == .array) "array.unpack " else "struct.unpack ");
try printType(m, x.ty, w);
try printType(allocator, m, x.ty, w);
try w.writeByte(' ');
try value(f, x.value, w);
try w.print(", next -> @{s}", .{f.blocks[x.next].name});
@@ -267,7 +271,7 @@ fn printOp(m: air.Module, f: air.Function, op: air.Op, w: *Writer) Writer.Error!
},
inline .enum_switch, .enum_take => |x| {
try w.writeAll(if (op == .enum_take) "enum.take " else "enum.switch ");
try printType(m, x.ty, w);
try printType(allocator, m, x.ty, w);
try w.writeByte(' ');
try value(f, x.value, w);
for (x.arms) |a| try w.print(", {s} -> @{s}", .{ m.variantName(x.ty, a.variant), f.blocks[a.block].name });
@@ -286,7 +290,7 @@ fn printOp(m: air.Module, f: air.Function, op: air.Op, w: *Writer) Writer.Error!
.trap => try w.writeAll("trap"),
.local_alloc => |t| {
try w.writeAll("local.alloc ");
try printType(m, t, w);
try printType(allocator, m, t, w);
},
.local_store => |x| try two(f, w, "local.store", x.local, x.value),
.local_zero => |v| try one(f, w, "local.zero", v),
@@ -303,7 +307,7 @@ fn printOp(m: air.Module, f: air.Function, op: air.Op, w: *Writer) Writer.Error!
.store => |x| try two(f, w, "store", x.borrow, x.value),
.array_splat => |x| {
try w.writeAll("array.splat ");
try printType(m, x.ty, w);
try printType(allocator, m, x.ty, w);
try w.writeByte(' ');
try value(f, x.value, w);
},
@@ -326,7 +330,7 @@ fn printOp(m: air.Module, f: air.Function, op: air.Op, w: *Writer) Writer.Error!
},
.buffer_new => |x| {
try w.writeAll("buffer.new ");
try printType(m, x.ty, w);
try printType(allocator, m, x.ty, w);
try w.print(" %{s}, %{s}", .{ f.values[x.n].name, f.values[x.cap].name });
try okErr(f, w, x.ok, x.err);
},
@@ -351,7 +355,7 @@ fn printOp(m: air.Module, f: air.Function, op: air.Op, w: *Writer) Writer.Error!
inline .own_new, .own_pack => |x, tag| {
if (tag == .own_pack) {
try w.writeAll("own.pack ");
try printType(m, x.ty, w);
try printType(allocator, m, x.ty, w);
try w.writeByte(' ');
try value(f, x.value, w);
try w.writeAll(", ");
@@ -403,7 +407,7 @@ fn printOp(m: air.Module, f: air.Function, op: air.Op, w: *Writer) Writer.Error!
.task_shield_end => |v| try one(f, w, "task.shield.end", v),
.channel_make => |x| {
try w.writeAll("channel.make ");
try printType(m, x.elem, w);
try printType(allocator, m, x.elem, w);
try w.writeAll(", ");
try value(f, x.cap, w);
try w.writeAll(", ");
@@ -525,6 +529,54 @@ fn two(f: air.Function, w: *Writer, op: []const u8, a: air.ValueId, b: air.Value
const parse = @import("parse.zig").parse;
test "deep array type printing retains suffix order and round trips canonically" {
var scratch = std.heap.ArenaAllocator.init(std.testing.allocator);
defer scratch.deinit();
const allocator = scratch.allocator();
const rows = try allocator.alloc(air.Type.Array, 65_536);
var t: air.Type = .{ .int = .u8 };
for (rows, 1..) |*row, len| {
row.* = .{ .elem = t, .len = len };
t = .{ .array = row };
}
const m: air.Module = .{ .name = "deep", .format_version = 0, .lang = .{ 0, 1 }, .features = &.{ "arrays", "ownership" }, .types = &.{}, .functions = &.{} };
var actual: Writer.Allocating = .init(allocator);
try printType(allocator, m, t, &actual.writer);
var expected: Writer.Allocating = .init(allocator);
for (rows) |_| try expected.writer.writeAll("array<");
try expected.writer.writeAll("u8");
for (1..rows.len + 1) |len| try expected.writer.print(", {d}>", .{len});
try std.testing.expectEqualStrings(expected.written(), actual.written());
var source: Writer.Allocating = .init(allocator);
try source.writer.writeAll("module deep\nair 0\nlang 0.1\nfeatures [arrays, ownership]\nfn @f(%x: ");
try source.writer.writeAll(expected.written());
try source.writer.writeAll(") -> void\neffects []\nentry:\n ret\n");
try roundTrip(source.written());
}
test "type printer retains all unary constructor spellings and leaf names" {
const allocator = std.testing.allocator;
const leaf: air.Type = .{ .named = 0 };
const m: air.Module = .{ .name = "test", .format_version = 0, .lang = .{ 0, 1 }, .features = &.{}, .types = &.{.{ .name = "Node", .span = .{ .line = 1, .col = 1 }, .kind = .{ .@"struct" = &.{} } }}, .functions = &.{} };
inline for (.{ .local, .ref, .mut, .slice, .slice_mut, .own, .own_array, .buffer, .task, .sender, .receiver, .mutex, .guard, .island, .frozen, .arc, .iref, .atomic }) |tag| {
const t: air.Type = @unionInit(air.Type, @tagName(tag), &leaf);
var out: Writer.Allocating = .init(allocator);
defer out.deinit();
try printType(allocator, m, t, &out.writer);
try std.testing.expectEqualStrings(@tagName(tag) ++ "<@Node>", out.written());
}
}
test "type printer propagates suffix allocation and buffered writer failures" {
const m: air.Module = .{ .name = "test", .format_version = 0, .lang = .{ 0, 1 }, .features = &.{}, .types = &.{}, .functions = &.{} };
const row: air.Type.Array = .{ .elem = .{ .int = .u8 }, .len = 1 };
var buf: [64]u8 = undefined;
var out: Writer = .fixed(&buf);
try std.testing.expectError(error.OutOfMemory, printType(std.testing.failing_allocator, m, .{ .array = &row }, &out));
out = .fixed(buf[0..6]);
try std.testing.expectError(error.WriteFailed, printType(std.testing.allocator, m, .{ .array = &row }, &out));
}
fn roundTrip(src: []const u8) !void {
var arena_state: std.heap.ArenaAllocator = .init(std.testing.allocator);
defer arena_state.deinit();
@@ -533,12 +585,12 @@ fn roundTrip(src: []const u8) !void {
const r1 = try parse(arena, "a.air", src);
try std.testing.expectEqual(@as(usize, 0), r1.diagnostics.len);
var out1: Writer.Allocating = .init(arena);
try print(r1.module.?, &out1.writer);
try print(arena, r1.module.?, &out1.writer);
const r2 = try parse(arena, "b.air", out1.written());
try std.testing.expectEqual(@as(usize, 0), r2.diagnostics.len);
var out2: Writer.Allocating = .init(arena);
try print(r2.module.?, &out2.writer);
try print(arena, r2.module.?, &out2.writer);
try std.testing.expectEqualStrings(out1.written(), out2.written());
}
@@ -579,7 +631,7 @@ test "canonical form of a messy module" {
const r = try parse(arena, "t.air", src);
try std.testing.expectEqual(@as(usize, 0), r.diagnostics.len);
var out: Writer.Allocating = .init(arena);
try print(r.module.?, &out.writer);
try print(arena, r.module.?, &out.writer);
try std.testing.expectEqualStrings(
\\module t.x
\\air 0
+1 -1
View File
@@ -65,7 +65,7 @@ pub const Context = struct {
pub fn typeName(c: *Context, t: air.Type) std.mem.Allocator.Error![]const u8 {
var w: std.Io.Writer.Allocating = .init(c.arena);
air.print.printType(c.module, t, &w.writer) catch return error.OutOfMemory;
air.print.printType(c.arena, c.module, t, &w.writer) catch return error.OutOfMemory;
return w.written();
}
};
+1 -1
View File
@@ -181,7 +181,7 @@ fn runSource(arena: std.mem.Allocator, io: std.Io, dir: std.Io.Dir, rel: []const
const parsed = try aji.air.parse.parse(arena, path, lowered.air);
if (parsed.module) |m| {
var w: std.Io.Writer.Allocating = .init(arena);
try aji.air.print.print(m, &w.writer);
try aji.air.print.print(arena, m, &w.writer);
if (!std.mem.eql(u8, w.written(), lowered.air)) return .{ .outcome = .fail, .detail = "lowered AIR is not canonical (parse → print differs)" };
}
const golden_path = try std.fmt.allocPrint(arena, "{s}.expected", .{rel});