Files
sx/examples/0609-comptime-inline-if.sx
agra e12f817e52 test: split 50-smoke.sx into per-section examples + add errors smoke
Break the monolithic examples/50-smoke.sx into 30 focused per-section examples,
filed into their category blocks (basic/types/comptime/memory/protocols/ffi),
each carrying only the top-level decls its section references (the protocols
section keeps the full preamble — its deps flow through UFCS method calls that
name-based extraction can't see). Outputs verified identical to the original
section blocks.

Add examples/1036-errors-failable-smoke.sx — an end-to-end error-handling example
(the E5.4 work): named + inferred error sets consumed via destructure, try (in
helpers), catch (bare-expr / match-body / diverging / no-binding), or
value-terminator, onfail+defer interleave, and error.X value + {} tag
interpolation.

Remove examples/50-smoke.sx. Suite: 324 passed, 0 failed.
2026-06-01 19:34:21 +03:00

47 lines
1.1 KiB
Plaintext

#import "modules/std.sx";
#import "modules/math/math.sx";
#import "modules/compiler.sx";
#import "modules/test.sx";
pkg :: #import "modules/testpkg";
main :: () {
// --- inline if (compile-time conditionals) ---
print("=== inline if ===\n");
{
// POINTER_SIZE is 8 on desktop (64-bit)
inline if POINTER_SIZE == 8 {
print("64-bit\n");
} else {
print("32-bit\n");
}
// OS enum comparison
inline if OS == .wasm {
print("wasm\n");
} else {
print("not wasm\n");
}
// != comparison
inline if OS != .unknown {
print("known os\n");
} else {
print("unknown os\n");
}
// nested inline if
inline if POINTER_SIZE != 4 {
inline if OS != .wasm {
print("desktop 64-bit\n");
} else {
print("wasm 64-bit??\n");
}
}
// POINTER_SIZE in regular (non-inline) if expression
ps := if POINTER_SIZE == 8 then "8" else "4";
print("pointer size via if: {}\n", ps);
}
}