// A fixed array whose dimension is a module-global named constant // (`N :: 16; [N]T`) has the same layout as a literal-dimension array // (`[16]T`): correct length and element stride for scalar, slice/pointer // (string), and struct element types. // Regression (issue 0083): a named-const dim resolved to length 0, giving a // 0-byte alloca — scalar reads returned garbage and string/struct elements // bus-errored. #import "modules/std.sx"; N :: 4; P :: struct { x: s64; y: s64; } main :: () { // Scalar elements: store then read back. a : [N]s64 = ---; a[0] = 7; a[3] = 42; print("scalar a0={} a3={}\n", a[0], a[3]); // Slice/pointer elements (string): used to bus-error. s : [N]string = ---; s[0] = "hi"; s[1] = "yo"; print("string s0={} s1={}\n", s[0], s[1]); // Struct elements. ps : [N]P = ---; ps[0] = P.{ x = 1, y = 2 }; ps[2] = P.{ x = 5, y = 6 }; print("struct p0x={} p0y={} p2x={}\n", ps[0].x, ps[0].y, ps[2].x); }