Surface rename of the signed integer family: s1..s64 become i1..i64
(u1..u64, usize, isize unchanged). 'string' keeps the s-prefix arm in
name classification; width parsing moves to the i-prefix arm next to
isize.
Internal TypeId tags follow the surface (.s8/.s16/.s32/.s64 ->
.i8/.i16/.i32/.i64), as do mono-key mangle fragments (ptr_i64,
tu_i64_bool) and all display/diagnostic formatting (i{d}).
Migrated in the same sweep: stdlib + examples + issue repros + FFI C
companions (shared symbol names like ffi_id_i64), expected
stdout/stderr/ir snapshots, specs.md, readme.md, CLAUDE.md/AGENTS.md,
implementation_plan.md, docs/, issue writeups. Vendored stb_image and
historical flow state left untouched.
zig build test: 426/426; examples suite: 595/595.
84 lines
1.8 KiB
Plaintext
84 lines
1.8 KiB
Plaintext
#import "modules/std.sx";
|
|
#import "modules/math";
|
|
#import "modules/build.sx";
|
|
#import "modules/std/test.sx";
|
|
pkg :: #import "tests/fixtures/testpkg";
|
|
|
|
add :: (a: i32, b: i32) -> i32 { a + b }
|
|
|
|
mul :: (a: i32, b: i32) -> i32 { a * b }
|
|
|
|
// #run compile-time constants
|
|
CT_VAL :: #run add(10, 15);
|
|
|
|
CT_MUL :: #run mul(6, 7);
|
|
|
|
CT_CHAIN :: #run add(CT_VAL, 5);
|
|
|
|
// #run compile-time optional tests
|
|
|
|
// #run compile-time optional tests
|
|
ct_opt_coalesce :: () -> i32 {
|
|
x: ?i32 = 42;
|
|
y: ?i32 = null;
|
|
return (x ?? 0) + (y ?? 99);
|
|
}
|
|
|
|
ct_opt_unwrap :: () -> i32 {
|
|
x: ?i32 = 77;
|
|
return x!;
|
|
}
|
|
|
|
ct_opt_guard :: () -> i32 {
|
|
x: ?i32 = 10;
|
|
if x == null { return -1; }
|
|
return x;
|
|
}
|
|
|
|
CT_OPT_COALESCE :: #run ct_opt_coalesce();
|
|
|
|
CT_OPT_UNWRAP :: #run ct_opt_unwrap();
|
|
|
|
CT_OPT_GUARD :: #run ct_opt_guard();
|
|
|
|
// #insert helpers
|
|
|
|
// #insert helpers
|
|
gen_code :: () -> string {
|
|
return "print(\"insert-ok\\n\");";
|
|
}
|
|
|
|
gen_val :: () -> string {
|
|
return "print(\"insert-gen: {}\\n\", 42);";
|
|
}
|
|
|
|
// --- Error handling (failable functions: sets, raise/try/catch/or/onfail) ---
|
|
|
|
main :: () {
|
|
|
|
// ========================================================
|
|
// 8. COMPILE-TIME
|
|
// ========================================================
|
|
print("=== 8. Comptime ===\n");
|
|
|
|
// #run constant
|
|
print("run-const: {}\n", CT_VAL);
|
|
|
|
// #run with expression
|
|
print("run-expr: {}\n", CT_MUL);
|
|
|
|
// #run chained dependency
|
|
print("run-chain: {}\n", CT_CHAIN);
|
|
|
|
// #run comptime optionals
|
|
print("ct-opt-coalesce: {}\n", CT_OPT_COALESCE); // ct-opt-coalesce: 141
|
|
print("ct-opt-unwrap: {}\n", CT_OPT_UNWRAP); // ct-opt-unwrap: 77
|
|
print("ct-opt-guard: {}\n", CT_OPT_GUARD); // ct-opt-guard: 10
|
|
|
|
// #insert with function
|
|
#insert gen_code();
|
|
|
|
// #insert additional
|
|
#insert gen_val();
|
|
}
|