diff options
| author | John Schmidt <john.schmidt.h@gmail.com> | 2024-02-11 22:55:13 +0100 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2024-02-26 17:03:20 -0800 |
| commit | f803761e13a65ccbc6a5508f2dc2d7723b010dab (patch) | |
| tree | a913a11999ae074ffb5e59bfb13c973f13f659b2 /test/behavior/tuple.zig | |
| parent | 7a045ede7ca26338dc553e1a0113d1de4daf1b95 (diff) | |
| download | zig-f803761e13a65ccbc6a5508f2dc2d7723b010dab.tar.gz zig-f803761e13a65ccbc6a5508f2dc2d7723b010dab.zip | |
Fix tuple default values
- Add default values to the list of comptime-known elements in
`zirValidatePtrArrayInit`
- In `structFieldValueComptime`, only assert `haveFieldInits` if we
enter the`fieldIsComptime` branch (otherwise they are not needed).
Diffstat (limited to 'test/behavior/tuple.zig')
| -rw-r--r-- | test/behavior/tuple.zig | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/behavior/tuple.zig b/test/behavior/tuple.zig index 36b36a2b71..3d5b132c0f 100644 --- a/test/behavior/tuple.zig +++ b/test/behavior/tuple.zig @@ -560,3 +560,17 @@ test "comptime fields in tuple can be initialized" { var a: T = .{ 0, 0 }; _ = &a; } + +test "tuple default values" { + const T = struct { + usize, + usize = 123, + usize = 456, + }; + + const t: T = .{1}; + + try expectEqual(1, t[0]); + try expectEqual(123, t[1]); + try expectEqual(456, t[2]); +} |
