diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2021-10-07 17:42:17 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2021-10-07 17:42:17 -0700 |
| commit | 75cecef63ccaffda32b7ec2dd2d6cc3cb0b3d23a (patch) | |
| tree | 40154037ee31701ccfa3484b7dedefdc8139baea /test/behavior/struct.zig | |
| parent | a0c44e806b70021203f5b9cf9af3b5049c40a75a (diff) | |
| download | zig-75cecef63ccaffda32b7ec2dd2d6cc3cb0b3d23a.tar.gz zig-75cecef63ccaffda32b7ec2dd2d6cc3cb0b3d23a.zip | |
stage2: fix returning structs byval from functions
Diffstat (limited to 'test/behavior/struct.zig')
| -rw-r--r-- | test/behavior/struct.zig | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/behavior/struct.zig b/test/behavior/struct.zig index d755c92c72..e3b0e4bbff 100644 --- a/test/behavior/struct.zig +++ b/test/behavior/struct.zig @@ -129,3 +129,18 @@ const MemberFnRand = struct { return r.seed; } }; + +test "return struct byval from function" { + const bar = makeBar2(1234, 5678); + try expect(bar.y == 5678); +} +const Bar = struct { + x: i32, + y: i32, +}; +fn makeBar2(x: i32, y: i32) Bar { + return Bar{ + .x = x, + .y = y, + }; +} |
