Files
sx/examples/types/0174-types-int-literal-boundaries.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

23 lines
745 B
Plaintext

// Boundary and exemption cases for the int-literal fits-check: extreme
// in-range values compile (incl. negated literals via the constant fold);
// width-64 types accept any representable literal; explicit `xx` / `cast`
// still truncate on request; literal call args check against param types.
#import "modules/std.sx";
clamp_i8 :: (v: i8) -> i8 { v }
main :: () {
a : i8 = -128;
b : i8 = 127;
c : u8 = 0;
d : u8 = 255;
e : u64 = 0x7FFFFFFFFFFFFFFF;
f : u32 = 0xFFFFFFFF;
g : i16 = -32768;
h : i8 = xx 300; // explicit truncation stays legal
i := cast(i8) 300; // cast form too
j : i8 = clamp_i8(-5);
print("{} {} {} {} {} {} {} {} {} {}\n", a, b, c, d, e, f, g, h, i, j);
}