On Sunday, 26 August 2018 at 10:17:51 UTC, Walter Bright wrote:
I'm not sure what you're referring to. I'm referring to the specified message, and the example:

struct Array
{
    int[] _payload;
    ~this() // (2)
    {
        import core.stdc.stdlib : free;
        free(_payload.ptr); // (3)
    }
}

class Scanner
{
    Array arr;
    this() @safe {}  // (1)
}

In order for (1) to be @safe, then the destructor it calls for arr (2) must also be @safe. But the destructor calls free() (3), which is not @safe. Therefore, the compilation fails. Inference does not solve this problem, because (2) is inferred as @system.


Yes but if Scanners constructor is nothrow then all is fine, since it won't unwind unless an error is thrown in which case it game over anyway.


Reply via email to