add regression test case. closes #3007
parent
21aed86a4a
commit
828abe046f
|
@ -32,6 +32,7 @@ comptime {
|
|||
_ = @import("behavior/bugs/2346.zig");
|
||||
_ = @import("behavior/bugs/2578.zig");
|
||||
_ = @import("behavior/bugs/2692.zig");
|
||||
_ = @import("behavior/bugs/3007.zig");
|
||||
_ = @import("behavior/bugs/3046.zig");
|
||||
_ = @import("behavior/bugs/3112.zig");
|
||||
_ = @import("behavior/bugs/3367.zig");
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
const std = @import("std");
|
||||
|
||||
const Foo = struct {
|
||||
free: bool,
|
||||
|
||||
pub const FooError = error{NotFree};
|
||||
};
|
||||
|
||||
var foo = Foo{ .free = true };
|
||||
var default_foo: ?*Foo = null;
|
||||
|
||||
fn get_foo() Foo.FooError!*Foo {
|
||||
if (foo.free) {
|
||||
foo.free = false;
|
||||
return &foo;
|
||||
}
|
||||
return error.NotFree;
|
||||
}
|
||||
|
||||
test "fixed" {
|
||||
default_foo = get_foo() catch null; // This Line
|
||||
std.testing.expect(!default_foo.?.free);
|
||||
}
|
Loading…
Reference in New Issue