Files
sx/examples/route/0823-route-all-own-wins-subform-wrappers.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

33 lines
1.0 KiB
Plaintext

// G4 — own-wins halves for the §D row-2 SUB-FORM wrappers (`?Named`, `[]Named`,
// `[N]Named`). Each wraps a named element type whose resolution recurses through
// the SAME source-aware `resolveCompound` element path that `*Named` uses (0822),
// so they share one routing mechanism rather than a per-form path. `main` authors
// its OWN `Box { m }` and flat-imports `dep.sx` (`Box { a }`); each wrapped
// element must bind main's own `Box`, observed by a `.m` access (disjoint field
// sets → a wrong-author binding is a hard compile error).
#import "modules/std.sx";
#import "0823-route-all-own-wins-subform-wrappers/dep.sx";
Box :: struct { m: i32; }
main :: () -> i32 {
seed : Box = ---;
seed.m = 1;
// ?Named element own-wins
opt : ?Box = seed;
o := opt!;
// [N]Named element own-wins
arr : [2]Box = ---;
arr[0].m = 2;
arr[1].m = 3;
// []Named element own-wins
sl : []Box = arr[0..2];
print("opt={} arr={} sl={} dep={}\n", o.m, arr[0].m, sl[1].m, dep_box());
0
}