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.
43 lines
1.6 KiB
Plaintext
43 lines
1.6 KiB
Plaintext
// Backtick raw identifier in TYPE position (the universal model, issue 0089):
|
|
// `` `name `` is the LITERAL identifier `name` used as a type reference, never
|
|
// the builtin/reserved spelling. A reserved type spelling (`i2`, `u8`, …) can
|
|
// therefore both DECLARE a type (struct / enum / union / error-set / alias) and
|
|
// be REFERENCED as that type via the backtick — while a BARE `i2` in type
|
|
// position remains the signed-int type (see `add` below) and a bare reserved-
|
|
// name declaration still errors (see examples/1141). The backtick is required
|
|
// to declare or reference these names; it is never part of the name's text.
|
|
// Regression (issue 0089 — attempt-4 universal raw identifier).
|
|
#import "modules/std.sx";
|
|
|
|
// Type-introducing decls whose NAME is a reserved spelling.
|
|
`i2 :: struct { x: i64; }
|
|
`i8 :: enum { A; B; }
|
|
`u16 :: union { i: i32; f: f32; }
|
|
`u32 :: error { Bad, Empty }
|
|
RawAlias :: `i2; // alias to a backtick-declared struct
|
|
|
|
// A bare `i2` in type position is still the 2-bit signed int.
|
|
add :: (a: i2, b: i2) -> i2 { return a + b; }
|
|
|
|
main :: () -> i32 {
|
|
// Reference the backtick struct as a type; field access works.
|
|
v : `i2 = ---;
|
|
v.x = 7;
|
|
|
|
// Reference via a normal alias too.
|
|
a : RawAlias = ---;
|
|
a.x = 11;
|
|
|
|
// Backtick enum / union type references.
|
|
e : `i8 = .A;
|
|
u : `u16 = ---;
|
|
u.i = 5;
|
|
|
|
print("struct = {}\n", v.x);
|
|
print("alias = {}\n", a.x);
|
|
print("enum = {}\n", e == .A);
|
|
print("union = {}\n", u.i);
|
|
print("bare = {}\n", add(1, 0)); // bare i2 = the 2-bit int type
|
|
return 0;
|
|
}
|