Files
sx/examples/packs/0536-packs-pack-as-value.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

26 lines
891 B
Plaintext

// Step 2.7 — pack-as-value diagnostics. A pack is comptime-only (Decision 1),
// so using the bare pack name where a runtime value is required is an error,
// with a context-tailored suggestion. All four categories below fire (the
// functions are monomorphized when called from main).
#import "modules/std.sx";
Show :: protocol { show :: (self: *Self) -> string; }
A :: struct {}
impl Show for A { show :: (self: *A) -> string => "A"; }
sink :: (v: i64) -> void { _ = v; }
storage :: (..xs: Show) -> void { y := xs; _ = y; } // A: store
call :: (..xs: Show) -> void { sink(xs); } // B: pass to a call
ret :: (..xs: Show) -> i64 { return xs; } // C: return
iter :: (..xs: Show) -> void { for xs (x) { _ = x; } } // D: runtime iterate
main :: () -> i32 {
storage(A.{});
call(A.{});
_ = ret(A.{});
iter(A.{});
0
}