lang: rename signed integer types sN -> iN

Surface rename of the signed integer family: s1..s64 become i1..i64
(u1..u64, usize, isize unchanged). 'string' keeps the s-prefix arm in
name classification; width parsing moves to the i-prefix arm next to
isize.

Internal TypeId tags follow the surface (.s8/.s16/.s32/.s64 ->
.i8/.i16/.i32/.i64), as do mono-key mangle fragments (ptr_i64,
tu_i64_bool) and all display/diagnostic formatting (i{d}).

Migrated in the same sweep: stdlib + examples + issue repros + FFI C
companions (shared symbol names like ffi_id_i64), expected
stdout/stderr/ir snapshots, specs.md, readme.md, CLAUDE.md/AGENTS.md,
implementation_plan.md, docs/, issue writeups. Vendored stb_image and
historical flow state left untouched.

zig build test: 426/426; examples suite: 595/595.
This commit is contained in:
agra
2026-06-12 09:31:53 +03:00
parent 515ecebea7
commit d8076b9333
1054 changed files with 6836 additions and 6839 deletions

View File

@@ -14,7 +14,7 @@ test "builtin types pre-populated" {
// Verify builtin slots
try std.testing.expectEqual(TypeInfo.void, table.get(.void));
try std.testing.expectEqual(TypeInfo.bool, table.get(.bool));
try std.testing.expectEqual(TypeInfo{ .signed = 32 }, table.get(.s32));
try std.testing.expectEqual(TypeInfo{ .signed = 32 }, table.get(.i32));
try std.testing.expectEqual(TypeInfo{ .unsigned = 8 }, table.get(.u8));
try std.testing.expectEqual(TypeInfo.f64, table.get(.f64));
try std.testing.expectEqual(TypeInfo.string, table.get(.string));
@@ -26,8 +26,8 @@ test "intern deduplicates structural types" {
var table = TypeTable.init(alloc);
defer table.deinit();
const ptr1 = table.ptrTo(.s32);
const ptr2 = table.ptrTo(.s32);
const ptr1 = table.ptrTo(.i32);
const ptr2 = table.ptrTo(.i32);
try std.testing.expectEqual(ptr1, ptr2);
const ptr3 = table.ptrTo(.f64);
@@ -39,8 +39,8 @@ test "slice and array interning" {
var table = TypeTable.init(alloc);
defer table.deinit();
const slice1 = table.sliceOf(.s32);
const slice2 = table.sliceOf(.s32);
const slice1 = table.sliceOf(.i32);
const slice2 = table.sliceOf(.i32);
try std.testing.expectEqual(slice1, slice2);
const arr1 = table.arrayOf(.u8, 10);
@@ -55,8 +55,8 @@ test "optional interning" {
var table = TypeTable.init(alloc);
defer table.deinit();
const opt1 = table.optionalOf(.s32);
const opt2 = table.optionalOf(.s32);
const opt1 = table.optionalOf(.i32);
const opt2 = table.optionalOf(.i32);
try std.testing.expectEqual(opt1, opt2);
const opt3 = table.optionalOf(.f64);
@@ -68,9 +68,9 @@ test "function type interning" {
var table = TypeTable.init(alloc);
defer table.deinit();
const params = &[_]TypeId{ .s32, .s32 };
const fn1 = table.functionType(params, .s64);
const fn2 = table.functionType(params, .s64);
const params = &[_]TypeId{ .i32, .i32 };
const fn1 = table.functionType(params, .i64);
const fn2 = table.functionType(params, .i64);
try std.testing.expectEqual(fn1, fn2);
const fn3 = table.functionType(params, .f64);
@@ -99,14 +99,14 @@ test "sizeOf builtins" {
try std.testing.expectEqual(@as(u32, 0), table.sizeOf(.void));
try std.testing.expectEqual(@as(u32, 1), table.sizeOf(.bool));
try std.testing.expectEqual(@as(u32, 4), table.sizeOf(.s32));
try std.testing.expectEqual(@as(u32, 8), table.sizeOf(.s64));
try std.testing.expectEqual(@as(u32, 4), table.sizeOf(.i32));
try std.testing.expectEqual(@as(u32, 8), table.sizeOf(.i64));
try std.testing.expectEqual(@as(u32, 1), table.sizeOf(.u8));
try std.testing.expectEqual(@as(u32, 4), table.sizeOf(.f32));
try std.testing.expectEqual(@as(u32, 8), table.sizeOf(.f64));
try std.testing.expectEqual(@as(u32, 16), table.sizeOf(.string));
try std.testing.expectEqual(@as(u32, 8), table.sizeOf(table.ptrTo(.s32)));
try std.testing.expectEqual(@as(u32, 16), table.sizeOf(table.sliceOf(.s32)));
try std.testing.expectEqual(@as(u32, 8), table.sizeOf(table.ptrTo(.i32)));
try std.testing.expectEqual(@as(u32, 16), table.sizeOf(table.sliceOf(.i32)));
}
test "typeName for builtins" {
@@ -114,7 +114,7 @@ test "typeName for builtins" {
var table = TypeTable.init(alloc);
defer table.deinit();
try std.testing.expectEqualStrings("s32", table.typeName(.s32));
try std.testing.expectEqualStrings("i32", table.typeName(.i32));
try std.testing.expectEqualStrings("bool", table.typeName(.bool));
try std.testing.expectEqualStrings("string", table.typeName(.string));
try std.testing.expectEqualStrings("void", table.typeName(.void));
@@ -128,7 +128,7 @@ test "pack type: construct, element access, intern dedup (N=3)" {
var table = TypeTable.init(alloc);
defer table.deinit();
const elems = &[_]TypeId{ .bool, .s32, .string };
const elems = &[_]TypeId{ .bool, .i32, .string };
const p1 = table.packType(elems);
const p2 = table.packType(elems);
try std.testing.expectEqual(p1, p2); // structural dedup
@@ -137,7 +137,7 @@ test "pack type: construct, element access, intern dedup (N=3)" {
try std.testing.expect(info == .pack);
try std.testing.expectEqual(@as(usize, 3), info.pack.elements.len);
try std.testing.expectEqual(TypeId.bool, info.pack.elements[0]);
try std.testing.expectEqual(TypeId.s32, info.pack.elements[1]);
try std.testing.expectEqual(TypeId.i32, info.pack.elements[1]);
try std.testing.expectEqual(TypeId.string, info.pack.elements[2]);
}
@@ -170,14 +170,14 @@ test "pack type: distinct element lists are distinct types" {
var table = TypeTable.init(alloc);
defer table.deinit();
const a = table.packType(&[_]TypeId{ .bool, .s32 });
const b = table.packType(&[_]TypeId{ .s32, .bool }); // order matters
const a = table.packType(&[_]TypeId{ .bool, .i32 });
const b = table.packType(&[_]TypeId{ .i32, .bool }); // order matters
const c = table.packType(&[_]TypeId{.bool}); // arity matters
try std.testing.expect(a != b);
try std.testing.expect(a != c);
try std.testing.expect(b != c);
// A pack is distinct from the tuple of the same elements.
const tup = table.intern(.{ .tuple = .{ .fields = &[_]TypeId{ .bool, .s32 }, .names = null } });
const tup = table.intern(.{ .tuple = .{ .fields = &[_]TypeId{ .bool, .i32 }, .names = null } });
try std.testing.expect(a != tup);
}
@@ -189,8 +189,8 @@ test "pack type: formatTypeName" {
var arena = std.heap.ArenaAllocator.init(alloc);
defer arena.deinit();
const p = table.packType(&[_]TypeId{ .bool, .s32, .string });
try std.testing.expectEqualStrings("pack(bool, s32, string)", table.formatTypeName(arena.allocator(), p));
const p = table.packType(&[_]TypeId{ .bool, .i32, .string });
try std.testing.expectEqualStrings("pack(bool, i32, string)", table.formatTypeName(arena.allocator(), p));
const empty = table.packType(&.{});
try std.testing.expectEqualStrings("pack()", table.formatTypeName(arena.allocator(), empty));
@@ -266,7 +266,7 @@ test "isUnsignedInt: builtin signedness classification" {
}
// Signed / non-integer builtins are not unsigned.
inline for (.{
TypeId.s8, TypeId.s16, TypeId.s32, TypeId.s64, TypeId.isize,
TypeId.i8, TypeId.i16, TypeId.i32, TypeId.i64, TypeId.isize,
TypeId.bool, TypeId.f32, TypeId.f64, TypeId.string,
TypeId.void, TypeId.any, TypeId.unresolved,
}) |ty| {
@@ -280,9 +280,9 @@ test "isUnsignedInt: user-defined arbitrary-width ints" {
defer table.deinit();
const u24_ty = table.intern(.{ .unsigned = 24 });
const s24_ty = table.intern(.{ .signed = 24 });
const i24_ty = table.intern(.{ .signed = 24 });
try std.testing.expect(table.isUnsignedInt(u24_ty));
try std.testing.expect(!table.isUnsignedInt(s24_ty));
try std.testing.expect(!table.isUnsignedInt(i24_ty));
// A non-integer user type is never unsigned.
const ptr_ty = table.ptrTo(.u32);
@@ -303,8 +303,8 @@ test "phase D: forward-decl field fill preserves intern key" {
// Full definition arrives later; same name (and nominal id) → same key.
const fields = [_]TypeInfo.StructInfo.Field{
.{ .name = table.internString("x"), .ty = .s64 },
.{ .name = table.internString("y"), .ty = .s64 },
.{ .name = table.internString("x"), .ty = .i64 },
.{ .name = table.internString("y"), .ty = .i64 },
};
table.updatePreservingKey(id, .{ .@"struct" = .{ .name = foo, .fields = &fields } });
@@ -322,7 +322,7 @@ test "phase D: anon rename re-keys intern_map" {
const anon = table.internString("__anon");
const fields = [_]TypeInfo.StructInfo.Field{
.{ .name = table.internString("x"), .ty = .s64 },
.{ .name = table.internString("x"), .ty = .i64 },
};
const id = table.internNominal(.{ .@"struct" = .{ .name = anon, .fields = &fields } }, 0);
try std.testing.expectEqual(id, table.findByName(anon).?);
@@ -387,13 +387,13 @@ test "phase D: parameterized protocol value struct interns stably" {
defer table.deinit();
// `instantiateParamProtocol` registers a `{ctx, __vtable}` value struct
// under a mangled name (e.g. `VL__s64`). Same instantiation → same id.
// under a mangled name (e.g. `VL__i64`). Same instantiation → same id.
const void_ptr = table.ptrTo(.void);
const fields = [_]TypeInfo.StructInfo.Field{
.{ .name = table.internString("ctx"), .ty = void_ptr },
.{ .name = table.internString("__vtable"), .ty = void_ptr },
};
const info: TypeInfo = .{ .@"struct" = .{ .name = table.internString("VL__s64"), .fields = &fields, .is_protocol = true } };
const info: TypeInfo = .{ .@"struct" = .{ .name = table.internString("VL__i64"), .fields = &fields, .is_protocol = true } };
const a = table.intern(info);
const b = table.intern(info);
try std.testing.expectEqual(a, b);
@@ -408,7 +408,7 @@ test "phase D: same display-name distinct nominal ids" {
defer table.deinit();
const foo = table.internString("Foo");
const f = [_]TypeInfo.StructInfo.Field{.{ .name = table.internString("x"), .ty = .s64 }};
const f = [_]TypeInfo.StructInfo.Field{.{ .name = table.internString("x"), .ty = .i64 }};
const base: TypeInfo = .{ .@"struct" = .{ .name = foo, .fields = &f } };
const a = table.internNominal(base, 1);
@@ -445,7 +445,7 @@ test "phase D: internNominal(.,0) is byte-identical to legacy intern (old==new)"
var table = TypeTable.init(alloc);
defer table.deinit();
const f = [_]TypeInfo.StructInfo.Field{.{ .name = table.internString("x"), .ty = .s64 }};
const f = [_]TypeInfo.StructInfo.Field{.{ .name = table.internString("x"), .ty = .i64 }};
const variants = [_]types.StringId{table.internString("v")};
const tags = [_]u32{7};
@@ -453,7 +453,7 @@ test "phase D: internNominal(.,0) is byte-identical to legacy intern (old==new)"
.{ .@"struct" = .{ .name = table.internString("S"), .fields = &f } },
.{ .@"enum" = .{ .name = table.internString("E"), .variants = &variants } },
.{ .@"union" = .{ .name = table.internString("U"), .fields = &f } },
.{ .tagged_union = .{ .name = table.internString("T"), .fields = &f, .tag_type = .s64 } },
.{ .tagged_union = .{ .name = table.internString("T"), .fields = &f, .tag_type = .i64 } },
.{ .error_set = .{ .name = table.internString("Err"), .tags = &tags } },
};
for (cases) |info| {