Files
ww/test/lang/global_slice_pseudofield_store_test.ww
Hojun-Cho 5ddada94e5 cgen: address module-global str/slice pseudo-field stores via the symbol
A module-global base has no frame slot; treating its local-lookup miss
as offset zero wrote .ptr/.len/.cap at the caller return address. LEAQ
the symbol like the struct-field global arms do. Both stages.
2026-08-07 23:00:08 +09:00

20 lines
538 B
Plaintext

// A module-global slice header is not a BP-relative local. Writing its
// pseudo-fields through offset zero overwrites the caller's saved control
// state instead of the global header.
package global_slice_pseudofield_store_test;
let values: []i64 = [10, 20, 30, 40];
let replacement: [2]i64 = [70, 80];
@test fn global_header_store() void = {
values.ptr = &replacement[0];
values.len = 1;
values.cap = 2;
values.len += 1;
assert(values.len == 2);
assert(values.cap == 2);
assert(values[0] == 70);
assert(values[1] == 80);
};