| 1 |
/* REQUIRED_ARGS: -preview=dip1021 |
| 2 |
TEST_OUTPUT: |
| 3 |
--- |
| 4 |
fail_compilation/ob1.d(23): Error: variable `ob1.mars.t` has undefined state and cannot be read |
| 5 |
--- |
| 6 |
https://issues.dlang.org/show_bug.cgi?id=21923 |
| 7 |
*/ |
| 8 |
|
| 9 |
@live: |
| 10 |
|
| 11 |
struct Handle |
| 12 |
{ |
| 13 |
private void* _handle; |
| 14 |
|
| 15 |
this(int n); |
| 16 |
~this(); |
| 17 |
scope void bar(); |
| 18 |
static void fido(ref Handle); |
| 19 |
} |
| 20 |
|
| 21 |
void mars() |
| 22 |
{ |
| 23 |
auto t = Handle(10); |
| 24 |
t.bar(); |
| 25 |
Handle.fido(t); // moves t to fido(), then destructor runs, causing error |
| 26 |
|
| 27 |
scope u = Handle(10); |
| 28 |
} |