Files
sx/examples/errors/1021-errors-main-exit-truncation.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

15 lines
601 B
Plaintext

// Entry-point exit-code truncation (ERR step E4.2, non-failable integer main).
// `main :: () -> T` (integer) exits with the return value truncated to u8 —
// matching C `main` / the OS exit-status byte, so the JIT (`sx run`) and an AOT
// binary agree. Here 1105 & 0xFF == 81, so this program exits 81 (NOT 1, which
// was the old buggy "out of 0..255 range -> failure" behavior).
//
// Run: ./zig-out/bin/sx run examples/238-main-exit-truncation.sx ; echo $? # 81
#import "modules/std.sx";
main :: () -> i32 {
print("returning 1105 -> exit {}\n", 1105 & 0xFF); // 81
return 1105;
}