Files
sx/examples/0768-modules-own-wins-nonleaf-bare-type.sx
agra d8076b9333 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.
2026-06-12 09:31:53 +03:00

45 lines
1.8 KiB
Plaintext

// Own-wins (0754 / issue 0105 case 3) holds at EVERY non-leaf bare-type site,
// not just the nominal leaf annotation. `main` flat-imports `dep.sx` (which
// authors a same-name `Widget { a, b }` = 16 bytes and `Nums :: [2]i32` = 8
// bytes) AND authors its OWN `Widget { a }` = 8 bytes and `Nums :: [2]i64` = 16
// bytes. Each bare reference below must resolve to MAIN's own author — the gate's
// source-keyed `.resolved` author — NOT whichever same-name flat import a global
// `findByName` / `struct_template_map` pick would return:
//
// - reflection / type-arg slot `size_of(Widget)` → 8 (own)
// - typed array-literal head `Nums.[…]` / size_of → 16 (own [2]i64)
// - type-as-value `t : Type = Widget`
// - type-category match arm `case Widget:` → own identity
//
// Regression (Phase E4 attempt-6, finding #1): before the bare-type gate carried
// the OWN author's source-keyed TypeId into the non-leaf sites, an own author
// produced `.proceed` and these sites fell through to a global `findByName` — so
// `size_of(Widget)` printed the IMPORTED type's 16 and `case Widget:` matched the
// imported nominal identity (describe → 222). `dep_sizes` proves dep's distinct
// types still resolve to THEIR own 16 + 8 = 24 inside dep.
#import "modules/std.sx";
#import "0768-modules-own-wins-nonleaf-bare-type/dep.sx";
Widget :: struct { a: i64; }
Nums :: [2]i64;
describe :: ($T: Type) -> i32 {
r := if T == {
case Widget: 111;
else: 222;
}
r
}
main :: () -> i32 {
print("reflection={}\n", size_of(Widget));
xs := Nums.[1, 2];
print("array={}\n", size_of(Nums));
t : Type = Widget;
print("typeval_eq={}\n", t == Widget);
print("match={}\n", describe(Widget));
print("dep={}\n", dep_sizes());
0
}