Files
sx/examples/diagnostics/1183-diagnostics-many-pointer-to-slice-rejected.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
870 B
Plaintext

// A many-pointer `[*]T` carries NO length, so it cannot coerce to a slice `[]T`
// implicitly — doing so would pass a bare 8-byte pointer where a 16-byte
// `{ptr,len}` fat pointer is expected, silently corrupting the callee's view of
// the data (garbage length, mis-aligned element reads). The compiler rejects it
// loudly and tells the user to supply the length via `ptr[0..len]`.
//
// Regression (issue 0141): this silent mis-coercion segfaulted the comptime VM
// and failed LLVM verification at runtime; it now produces a clean diagnostic.
#import "modules/std.sx";
sum :: (s: []i64) -> i64 {
total := 0;
for s (x) { total += x; }
return total;
}
main :: () -> i32 {
xs : List(i64) = .{};
xs.append(10);
xs.append(20);
r := sum(xs.items); // [*]i64 → []i64 — needs xs.items[0..xs.len]
print("{}\n", r);
return 0;
}