Files
sx/examples/0812-modules-same-name-error-set-own-wins.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

29 lines
1.3 KiB
Plaintext

// E6b — own-wins-over-flat for ERROR-SET per-decl nominal identity. `main`
// flat-imports `dep.sx` (which authors `IoErr { Net }`) AND authors its OWN
// `IoErr { Disk }`. A bare `IoErr` reference in `main` resolves to `main`'s OWN
// author, not the flat-imported one (the querying source's author wins outright —
// no ambiguity), so `e : IoErr = error.Disk` binds `main`'s set (whose `Disk` tag
// dep's `IoErr` lacks) while `dep_err()` returns dep's DISTINCT `IoErr`.
//
// Fail-before (pre-E6b): the stateless `type_bridge.resolveInlineErrorSet`
// `findByName` short-circuit interned ONE global last-wins `IoErr`, so `main`'s
// `IoErr` and dep's `IoErr` collapsed to a single nominal. Whichever author won
// the global slot, the OTHER module's tag is not in it — so exactly one of
// `error.Disk` (main) / `error.Net` (dep, in `dep_err`'s body) fails its
// membership check and the program exits 1.
//
// Pass-after: distinct nominal TypeIds — `error.Disk` validates against main's
// `{ Disk }` and `error.Net` against dep's `{ Net }`, both pass, exit 0.
#import "modules/std.sx";
#import "0812-modules-same-name-error-set-own-wins/dep.sx";
IoErr :: error { Disk }
main :: () -> i32 {
e : IoErr = error.Disk;
d := dep_err();
print("own={} dep={}\n", e, d);
0
}