Can anyone illuminate me as to where this destructor call is coming from?
struct Thing
{
static int x;
this(typeof(null)) pure {} // <-- comment this line and the error goes away
~this() { ++x; }
}
Thing fun() pure
{
return Thing(null);
}
error : `pure` function `urt.string.string.fun` cannot call impure destructor `urt.string.string.Thing.~this`
Shouldn't NVRO construct the result in place and elide the copy/move? I would not expect any call to the destructor in fun()...
Also surprisingly, if I comment out the constructor, the compile error about the destructor goes away. I can't see why the constructor's existence affects the destruction semantics in fun()?