This commit is contained in:
agra
2026-03-04 17:12:56 +02:00
parent 67e02a20a5
commit 22bc2439ce
7 changed files with 217 additions and 18 deletions

View File

@@ -769,6 +769,12 @@ END;
ip3 := @out3.inner;
print("ptr-nested-field: {} {} {}\n", ip3.a, ip3.b, ip3.c);
// Store to many-pointer field must not corrupt adjacent memory
MpHolder :: struct { items: [*]s64; sentinel: s64; }
mph := MpHolder.{ items = xx 0, sentinel = 42 };
mph.items = xx 0;
print("mp-store-sentinel: {}\n", mph.sentinel);
// --- Vectors ---
vc := vec3(1, 3, 2);
print("vec-construct: {}\n", vc);
@@ -3165,6 +3171,10 @@ END;
print("wasm 64-bit??\n");
}
}
// POINTER_SIZE in regular (non-inline) if expression
ps := if POINTER_SIZE == 8 then "8" else "4";
print("pointer size via if: {}\n", ps);
}
// ── Trailing commas ──────────────────────────────────────────

View File

@@ -0,0 +1,55 @@
// Test: compound assignment operators on global variables
// Ensures += -= *= /= %= &= |= ^= <<= >>= all do load-modify-store
#import "modules/std.sx";
g_add : s64 = 10;
g_sub : s64 = 10;
g_mul : s64 = 10;
g_div : s64 = 100;
g_mod : s64 = 10;
g_and : s64 = 0xff;
g_or : s64 = 0x0f;
g_xor : s64 = 0xff;
g_shl : s64 = 1;
g_shr : s64 = 256;
main :: () -> void {
// += repeated: should accumulate, not reset
g_add += 1;
g_add += 1;
g_add += 1;
print("add: {}\n", g_add); // 13
g_sub -= 3;
g_sub -= 2;
print("sub: {}\n", g_sub); // 5
g_mul *= 2;
g_mul *= 3;
print("mul: {}\n", g_mul); // 60
g_div /= 5;
g_div /= 4;
print("div: {}\n", g_div); // 5
g_mod %= 3;
print("mod: {}\n", g_mod); // 1
g_and &= 0x0f;
print("and: {}\n", g_and); // 15
g_or |= 0xf0;
print("or: {}\n", g_or); // 255
g_xor ^= 0x0f;
print("xor: {}\n", g_xor); // 240
g_shl <<= 4;
g_shl <<= 2;
print("shl: {}\n", g_shl); // 64
g_shr >>= 3;
g_shr >>= 2;
print("shr: {}\n", g_shr); // 8
}