[Issue 11574] Improper behavior of scope(failure)

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Oct 6 06:01:19 PDT 2014


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

Kenji Hara <k.hara.pg at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |INVALID

--- Comment #6 from Kenji Hara <k.hara.pg at gmail.com> ---
(In reply to Shammah Chancellor from comment #0)
> It was brought to my attention that scope(failure) can prevent the bubbling
> of exceptions by returning from the failure statement.   This is bad
> behavior as scope failures can unintentionally prevent other scope failures
> from occurring.

>      scope(failure) { writeln("What?");} // <-- NEVER EXECUTED?!
>      scope(failure) {

scope(failure) is reached when an exception is thrown. In other words, it is on
the "exceptional code path". And in scope(failure), you can go back to the
regular code path by using return statement, and that's exactly what you doing
there for error handling.

So, the outer scope(failure) is never reached. There's no bug.
Therefore I close this issue as resolved invalid.

---

However, as you can see, the outer scope(failure) is not reachable, but current
dmd does not warn it even if you specify -w switch.

For that, I opened an enhancement issue 13575.

--


More information about the Digitalmars-d-bugs mailing list