Files
sx/examples/modules/0812-modules-same-name-error-set-own-wins.sx
agra 66bdc70bf1 test: group examples into per-category folders
Move examples/*.sx and their expected/ snapshots into per-category
subfolders (examples/<category>/...). Folder = leading filename token,
with ffi-objc/ffi-jni kept whole; filenames are unchanged. The corpus
runner and LSP sweep now discover each category's expected/ dir, while
issues/ stays flat. Example 1058's repo-root-relative companion import
is made file-relative. Path strings embedded in 164 snapshots were
regenerated (path-only changes). Test-layout docs in CLAUDE.md updated.
2026-06-21 14:41:34 +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
}