| author | |
| committer | |
| log | 828abe046f965371aabfe53d57b4a93956531707 |
| tree | a42acd79ce01be9156b8f6f5b513740c80e98c42 |
| parent | 21aed86a4a33b51857d82e4d8ed12ba3d4183de2 |
| signature | Commit is signed but in an unrecognized format. |
2 files changed, 24 insertions(+), 0 deletions(-)
test/stage1/behavior.zig+1| ... | ... | @@ -32,6 +32,7 @@ comptime { |
| 32 | 32 | _ = @import("behavior/bugs/2346.zig"); |
| 33 | 33 | _ = @import("behavior/bugs/2578.zig"); |
| 34 | 34 | _ = @import("behavior/bugs/2692.zig"); |
| 35 | _ = @import("behavior/bugs/3007.zig"); | |
| 35 | 36 | _ = @import("behavior/bugs/3046.zig"); |
| 36 | 37 | _ = @import("behavior/bugs/3112.zig"); |
| 37 | 38 | _ = @import("behavior/bugs/3367.zig"); |
test/stage1/behavior/bugs/3007.zig created+23| ... | ... | @@ -0,0 +1,23 @@ |
| 1 | const std = @import("std"); | |
| 2 | ||
| 3 | const Foo = struct { | |
| 4 | free: bool, | |
| 5 | ||
| 6 | pub const FooError = error{NotFree}; | |
| 7 | }; | |
| 8 | ||
| 9 | var foo = Foo{ .free = true }; | |
| 10 | var default_foo: ?*Foo = null; | |
| 11 | ||
| 12 | fn get_foo() Foo.FooError!*Foo { | |
| 13 | if (foo.free) { | |
| 14 | foo.free = false; | |
| 15 | return &foo; | |
| 16 | } | |
| 17 | return error.NotFree; | |
| 18 | } | |
| 19 | ||
| 20 | test "fixed" { | |
| 21 | default_foo = get_foo() catch null; // This Line | |
| 22 | std.testing.expect(!default_foo.?.free); | |
| 23 | } |