[Issue 13501] [REG2.052] Crash with throwing in scope(failure) after throwing in scope(success)

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Nov 8 06:25:02 UTC 2020


https://issues.dlang.org/show_bug.cgi?id=13501

--- Comment #6 from Vladimir Panteleev <dlang-bugzilla at thecybershadow.net> ---
I can understand such limitations being present for scope(exit), but not for
scope(success). scope(success) blocks are trivially lowered by inserting code
before all returns (or other statements that normally leave the scope), so they
should not in principle be special as far as exceptions are concerned.

If the problem is generally about throwing while an exception is in flight, I
feel like this is too useful to give up at the point, because error recovery in
principle may be a non-trivial operation that itself may throw.

> The spec is correct here, and the compiler should deprecate throwing in the
> scope statement.

Such a deprecation would need to be about any and all nothrow code, not just
throw statements, which would be a major breaking change. It would, at least,
break the pattern:

        foreach (foo; foos)
        {
                scope(failure) stderr.writeln("Error while processing foo" ,
foo, ":");
                processFoo(foo);
        }

because the writeln may throw.

--


More information about the Digitalmars-d-bugs mailing list