On Wednesday, 21 March 2018 at 08:49:11 UTC, Mike Franklin wrote:

I think `rt_finalize` can be made `@nogc` in the runtime.

And this is where you're wrong. Consider this:

class A {
    @nogc ~this() {}
}

class B : A {
    ~this() {}
}

A a = new B();
destroy(a); // Is this @nogc?


Essentially, since @nogc and other qualifiers aren't inherited on dtors, it's impossible to know if destroying an instance of a non-final class is @nogc.

There's one case where you can: final classes where no superclass and no member defines a non-@nogc destructor.

In order for this to be done in the general case, dtors need to inherit their qualifiers somehow. That's at the very least a DIP, and any chosen path is highly likely to break existing code.

--
  Simen

Reply via email to