add test case for defer modifying return value before returned
See #961
This commit is contained in:
parent
01ff0d4d62
commit
6c195ede54
|
@ -76,3 +76,20 @@ fn testNestedFnErrDefer() anyerror!void {
|
|||
};
|
||||
return S.baz();
|
||||
}
|
||||
|
||||
test "return variable while defer expression in scope to modify it" {
|
||||
const S = struct {
|
||||
fn doTheTest() void {
|
||||
expect(notNull().? == 1);
|
||||
}
|
||||
|
||||
fn notNull() ?u8 {
|
||||
var res: ?u8 = 1;
|
||||
defer res = null;
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
S.doTheTest();
|
||||
comptime S.doTheTest();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user