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.
26 lines
913 B
Plaintext
26 lines
913 B
Plaintext
// Failable `or` value-terminator (ERR step E2.4a). `lhs or value` where `lhs`
|
|
// is a value-carrying failable (`-> (T, !E)`): on success the result is the
|
|
// LHS value; on failure the LHS error is discarded and the result is the
|
|
// terminator value. The whole expression is non-failable (type T). The chain
|
|
// form (`try a or try b`) needs fallback-target routing and lands in E2.4b.
|
|
// Rejections: `examples/232-failable-or-reject.sx`.
|
|
|
|
#import "modules/std.sx";
|
|
|
|
E :: error { Bad, Empty }
|
|
|
|
parse :: (n: i32) -> (i32, !E) {
|
|
if n < 0 { raise error.Bad; }
|
|
if n == 0 { raise error.Empty; }
|
|
return n * 2;
|
|
}
|
|
|
|
main :: () -> i32 {
|
|
a := parse(5) or 0; // success → 10
|
|
b := parse(-1) or 99; // Bad → 99 (terminator)
|
|
c := parse(0) or 7; // Empty → 7 (terminator)
|
|
r := a + b + c; // 10 + 99 + 7 = 116
|
|
print("or result: {}\n", r);
|
|
return r;
|
|
}
|