On 8/25/2018 5:52 PM, David Nadlinger wrote:
On Saturday, 25 August 2018 at 22:53:44 UTC, Walter Bright wrote:
On 8/25/2018 2:46 PM, David Nadlinger wrote:
At least for the transition period, I'd have attributes only apply to the user-specified code and infer them for the actual full constructor. (We can still print a deprecation warning if they don't match.) —David

Inferring is not good enough, for example:

https://github.com/dlang/dmd/pull/6816#issuecomment-307972790

There the @safe constructor is calling a destructor that calls free(). It can't be inferred as @safe.

How did you interpret "only apply to the user-specified code"? In this example, the `@safe` in `this() @safe {}` would only apply to `{}`.

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.


can be supplemented with deprecation warnings if the specified "inner" and inferred "outer" attributes don't match.

Yes, and that's probably the only viable way forward with this. But Chris' ox will get gored, as 2009 code will not compile anymore without modification after the deprecation period expires.

Reply via email to