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.
This commit is contained in:
19
test/lang/global_slice_pseudofield_store_test.ww
Normal file
19
test/lang/global_slice_pseudofield_store_test.ww
Normal file
@@ -0,0 +1,19 @@
|
||||
// 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);
|
||||
};
|
||||
Reference in New Issue
Block a user