aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/struct_llvm.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-12-21 20:34:27 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-12-21 20:34:27 -0700
commit88be5bd81decab792cdb5b749b4bb5cf6d71e877 (patch)
treef5eed00970c7e97581e8382ae37d08ef177d431f /test/behavior/struct_llvm.zig
parent06d751dbb3c9cc4e09f2eb7250a242dc6b2423bc (diff)
downloadzig-88be5bd81decab792cdb5b749b4bb5cf6d71e877.tar.gz
zig-88be5bd81decab792cdb5b749b4bb5cf6d71e877.zip
Sema: fix empty struct init
* Extract common logic between `zirStructInitEmpty` and `zirStructInit`. * `resolveTypeFields` additionally sets status to `have_layout` if the total number of fields is 0.
Diffstat (limited to 'test/behavior/struct_llvm.zig')
-rw-r--r--test/behavior/struct_llvm.zig11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/behavior/struct_llvm.zig b/test/behavior/struct_llvm.zig
index 5c364e183e..5c8159cb0b 100644
--- a/test/behavior/struct_llvm.zig
+++ b/test/behavior/struct_llvm.zig
@@ -66,3 +66,14 @@ test "self-referencing struct via array member" {
x = T{ .children = .{&x} };
try expect(x.children[0] == &x);
}
+
+test "empty struct method call" {
+ const es = EmptyStruct{};
+ try expect(es.method() == 1234);
+}
+const EmptyStruct = struct {
+ fn method(es: *const EmptyStruct) i32 {
+ _ = es;
+ return 1234;
+ }
+};