Files
sx/examples/modules/0764-modules-import-generic-head-non-transitive.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

25 lines
1.1 KiB
Plaintext

// `#import` is non-transitive for a PARAMETERIZED TYPE HEAD (a generic-struct
// constructor like `Box(i64)`), exactly like a bare leaf type (0763) and like
// values/functions (0706): when A imports B and B imports C, A must NOT see C's
// top-level generic type `Box`. This file imports `b.sx` (which imports `c.sx`)
// and instantiates C's generic `Box(i64)` directly — the compiler rejects the
// head with a "type ... is not visible; #import the module that declares it"
// diagnostic, BEFORE instantiating the template.
//
// `b.sx` ↔ `c.sx` together still compile: `b_make`'s `Box(i64)` resolves because
// b.sx directly imports c.sx (the head is one flat hop away there, two from a
// file that imports b.sx).
//
// Regression (Phase E4): before the bare-head gate went single-hop this 2-flat-
// hop generic head was wrongly visible — the head lookup hit the global
// `struct_template_map` before any source-aware visibility check.
#import "modules/std.sx";
#import "0764-modules-import-generic-head-non-transitive/b.sx";
main :: () -> i32 {
x : Box(i64) = .{ v = 3 };
print("{}\n", x.v);
0
}