Commit 50a1ca24ca

Cody Tapscott <topolarity@tapscott.me>
2022-03-14 18:37:23
Add test for issue #11139
1 parent 1f76b4c
Changed files (2)
test
behavior
test/behavior/bugs/11139.zig
@@ -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;
+}
test/behavior.zig
@@ -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");