D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 11542 - scope(failure) messes up nothrow checking
Summary: scope(failure) messes up nothrow checking
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: accepts-invalid, pull
Depends on:
Blocks:
 
Reported: 2013-11-18 10:11 UTC by Andrei Alexandrescu
Modified: 2014-05-28 06:55 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Andrei Alexandrescu 2013-11-18 10:11:05 UTC
This code compiles:

void fun() nothrow
{
    scope(failure) {}
    throw new Exception("so sue me");
}

Generally the presence of scope(failure) completely shuts down checking for nothrow. See discussion in http://forum.dlang.org/thread/l6ccae$2cmt$1@digitalmars.com?page=3#post-20131118183251.63faaba7:40marco-leise for a sketch of the desirable/correct behavior.
Comment 1 Andrei Alexandrescu 2013-11-18 10:13:13 UTC
To wit, this should work under the new semantics:

void fun() nothrow
{
    scope(failure) { throw new Error("wowzers"); }
    throw new Exception("so sue me");
}

This is because nothrow functions may still throw Error. This should work as well:

void fun() nothrow
{
    scope(failure) assert(0);
    throw new Exception("so sue me");
}
Comment 3 github-bugzilla 2014-05-28 06:55:56 UTC
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/aad35c3af1132b59b906171a155f0e21da24c59b
fix Issue 11542 - scope(failure) messes up nothrow checking

https://github.com/D-Programming-Language/dmd/commit/b72ed88d2394188ea2c08cfbe5b3d2fe8e88c3ef
Merge pull request #3592 from 9rnsr/fix11542

Issue 11542 & 12809 - Improve blockExit calculation on try-catch-finally statement