commit c9a5a6b83abaeef232ce3f0d2407c59f8769e9e5 (tree) parent 3b4a6679a6422d68cb1ee4ecd31819b527b01c3b Author: Andrew Kelley <andrew@ziglang.org> Date: Fri, 20 Sep 2019 13:19:06 -0400 add test case for already fixed bug closes #3046 Diffstat:
| M | test/stage1/behavior.zig | | | 1 | + |
| A | test/stage1/behavior/bugs/3046.zig | | | 19 | +++++++++++++++++++ |
2 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/test/stage1/behavior.zig b/test/stage1/behavior.zig @@ -31,6 +31,7 @@ comptime { _ = @import("behavior/bugs/2346.zig"); _ = @import("behavior/bugs/2578.zig"); _ = @import("behavior/bugs/2692.zig"); + _ = @import("behavior/bugs/3046.zig"); _ = @import("behavior/bugs/3112.zig"); _ = @import("behavior/bugs/394.zig"); _ = @import("behavior/bugs/421.zig"); diff --git a/test/stage1/behavior/bugs/3046.zig b/test/stage1/behavior/bugs/3046.zig @@ -0,0 +1,19 @@ +const std = @import("std"); +const expect = std.testing.expect; + +const SomeStruct = struct { + field: i32, +}; + +fn couldFail() anyerror!i32 { + return 1; +} + +var some_struct: SomeStruct = undefined; + +test "fixed" { + some_struct = SomeStruct{ + .field = couldFail() catch |_| i32(0), + }; + expect(some_struct.field == 1); +}