Add test for issue #11139

This commit is contained in:
Cody Tapscott 2022-03-14 10:37:23 -07:00 committed by Andrew Kelley
parent 1f76b4c6b8
commit 50a1ca24ca
2 changed files with 26 additions and 0 deletions

View File

@ -62,6 +62,7 @@ test {
_ = @import("behavior/bugs/11100.zig");
_ = @import("behavior/bugs/10970.zig");
_ = @import("behavior/bugs/11046.zig");
_ = @import("behavior/bugs/11139.zig");
_ = @import("behavior/bugs/11165.zig");
_ = @import("behavior/call.zig");
_ = @import("behavior/cast.zig");

View File

@ -0,0 +1,25 @@
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;
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
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;
}