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.
58 lines
2.0 KiB
Plaintext
58 lines
2.0 KiB
Plaintext
// A store to a module-global array element writes the global's live storage,
|
|
// so a subsequent read sees the stored value — not the array initializer.
|
|
// Covers constant index, variable index, and a cross-function store, on a
|
|
// scalar global array, a struct-element global array (element-stride), and a
|
|
// nested-array global (recursive lvalue).
|
|
// Regression (issue 0079): global-array element stores were silently dropped
|
|
// (read returned the initializer) because the indexed lvalue base loaded the
|
|
// global by value into a temp instead of addressing the global's storage.
|
|
|
|
#import "modules/std.sx";
|
|
|
|
g : [3]i64 = .[10, 20, 30];
|
|
|
|
Pair :: struct { a: i64; b: i64; }
|
|
gp : [2]Pair = .[ .{ a = 1, b = 2 }, .{ a = 3, b = 4 } ];
|
|
|
|
grid : [2][3]i64 = .[ .[0, 0, 0], .[0, 0, 0] ];
|
|
|
|
write_global :: (i: i64, v: i64) { g[i] = v; }
|
|
|
|
main :: () {
|
|
// Scalar global array — const index.
|
|
g[1] = 222;
|
|
print("g[1]={}\n", g[1]); // 222
|
|
|
|
// Scalar global array — variable index.
|
|
k := 2;
|
|
g[k] = 333;
|
|
print("g[k]={}\n", g[k]); // 333
|
|
|
|
// Scalar global array — store from another function.
|
|
write_global(0, 111);
|
|
print("g[0]={}\n", g[0]); // 111
|
|
|
|
// Struct-element global array (16-byte stride) — const and var index.
|
|
gp[0] = .{ a = 10, b = 20 };
|
|
j := 1;
|
|
gp[j] = .{ a = 30, b = 40 };
|
|
print("gp[0]={},{}\n", gp[0].a, gp[0].b); // 10,20
|
|
print("gp[j]={},{}\n", gp[j].a, gp[j].b); // 30,40
|
|
|
|
// Nested-array global — element is [3]i64, recursive indexed lvalue.
|
|
grid[1][2] = 7;
|
|
r := 0;
|
|
grid[r][0] = 5;
|
|
print("grid[1][2]={}\n", grid[1][2]); // 7
|
|
print("grid[0][0]={}\n", grid[r][0]); // 5
|
|
|
|
if g[1] == 222 and g[2] == 333 and g[0] == 111
|
|
and gp[0].a == 10 and gp[0].b == 20
|
|
and gp[1].a == 30 and gp[1].b == 40
|
|
and grid[1][2] == 7 and grid[0][0] == 5 {
|
|
print("PASS\n");
|
|
} else {
|
|
print("FAIL: global array element store dropped\n");
|
|
}
|
|
}
|