Files
sx/examples/modules/0776-modules-bare-generic-static-method-visible-author.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

28 lines
1.4 KiB
Plaintext

// A BARE generic struct head used as a STATIC-METHOD-CALL target
// (`Box(i64).make(7)`) must instantiate — and call the method of — the template
// authored by the single bare-VISIBLE author, NOT the global last-wins
// `struct_template_map` (and its name-keyed `Box.make`), which a NON-visible
// 2-flat-hop same-name template can win.
//
// `b.sx` declares a one-field `Box($T)` (size 8) with its own `make`, and itself
// flat-imports `c.sx`, which declares a two-field `Box($T)` (size 16) with its
// own `make`. This file flat-imports ONLY `b.sx`, so `b.Box` is one flat hop away
// (visible) and `c.Box` is two hops away (NOT bare-visible, mirrors
// 0764/0774/0706). The static-method head `Box(i64).make(7)` must select `b.Box`
// (size 8) for BOTH the instantiated type layout and the method body.
//
// Regression (Phase E4 finding #1, static-method site): before the static-method
// head consulted the source-keyed visible author, `size_of(Box(i64))` correctly
// picked the visible `b.Box` (8) but `Box(i64).make(7)` instantiated the global
// last-wins `c.Box` and ran `c.Box.make`, returning a 16-byte value. Fail-before
// printed `size=8 xtype=16 x=7`.
#import "modules/std.sx";
#import "0776-modules-bare-generic-static-method-visible-author/b.sx";
main :: () -> i32 {
x := Box(i64).make(7);
print("size={} xtype={} x={}\n", size_of(Box(i64)), size_of(type_of(x)), x.x);
0
}