diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2021-12-21 20:34:27 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2021-12-21 20:34:27 -0700 |
| commit | 88be5bd81decab792cdb5b749b4bb5cf6d71e877 (patch) | |
| tree | f5eed00970c7e97581e8382ae37d08ef177d431f /test/behavior/struct_llvm.zig | |
| parent | 06d751dbb3c9cc4e09f2eb7250a242dc6b2423bc (diff) | |
| download | zig-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.zig | 11 |
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; + } +}; |
