diff --git a/test/stage1/behavior.zig b/test/stage1/behavior.zig index e56fc7ba7f335bb8976578485cb69184acee5b82..9b7f4305c28b5f7ceb383a50eac61637d8b89552 100644 --- 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 new file mode 100644 index 0000000000000000000000000000000000000000..709198fd584eeebec9368d64ab9107e863ddc17c --- /dev/null +++ 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); +}