aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/struct.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-03-15 19:21:58 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-03-15 19:21:58 -0700
commit9a6fa67cbc7e5771f3770c0cb7d6d2c6bafb6957 (patch)
tree4ee6f2f8ebf858321d970b2da9e7191475827c6e /test/behavior/struct.zig
parentfd43434149658ee482428714e05722e5a12fdecc (diff)
downloadzig-9a6fa67cbc7e5771f3770c0cb7d6d2c6bafb6957.tar.gz
zig-9a6fa67cbc7e5771f3770c0cb7d6d2c6bafb6957.zip
Sema: only do store_ptr tuple optimization for arrays
Check the big comment in the diff for more details. Fixes default-initialization of structs from empty struct literals.
Diffstat (limited to 'test/behavior/struct.zig')
-rw-r--r--test/behavior/struct.zig9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/behavior/struct.zig b/test/behavior/struct.zig
index abd24967bb..8383b81cd5 100644
--- a/test/behavior/struct.zig
+++ b/test/behavior/struct.zig
@@ -1281,3 +1281,12 @@ test "typed init through error unions and optionals" {
try S.doTheTest();
comptime try S.doTheTest();
}
+
+test "initialize struct with empty literal" {
+ if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
+ if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
+
+ const S = struct { x: i32 = 1234 };
+ var s: S = .{};
+ try expect(s.x == 1234);
+}