zig/test/behavior/bugs/11139.zig
Andrew Kelley 2f92d1a026 stage2: fixups for topolarity-comptime-memory-reinterp branch
* don't store `has_well_defined_layout` in memory.
 * remove struct `hasWellDefinedLayout` logic. it's just
   `layout != .Auto`. This means we only need one implementation, in
   Type.
 * fix some of the cases being wrong in `hasWellDefinedLayout`, such as
   optional pointers.
 * move `tag_ty_inferred` field into a position that makes it more
   obvious how the struct layout will be done. Also we don't have a
   compiler that intelligently moves fields around so this layout is
   better.
 * Sema: don't `resolveTypeLayout` in `zirCoerceResultPtr` unless
   necessary.
 * Rename `ComptimePtrLoadKit` `target` field to `pointee` to avoid
   confusion with `target`.
2022-03-14 21:43:03 -07:00

26 lines
700 B
Zig

const std = @import("std");
const builtin = @import("builtin");
const expect = std.testing.expect;
test "store array of array of structs at comptime" {
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
try expect(storeArrayOfArrayOfStructs() == 15);
comptime try expect(storeArrayOfArrayOfStructs() == 15);
}
fn storeArrayOfArrayOfStructs() u8 {
const S = struct {
x: u8,
};
var cases = [_][1]S{
[_]S{
S{ .x = 15 },
},
};
return cases[0][0].x;
}