[Issue 13575] New: Unreachable scope(failure) should be warned
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Mon Oct 6 05:47:53 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=13575
Issue ID: 13575
Summary: Unreachable scope(failure) should be warned
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: diagnostic
Severity: enhancement
Priority: P1
Component: DMD
Assignee: nobody at puremagic.com
Reporter: k.hara.pg at gmail.com
>From issue 11574:
import std.stdio;
void someFunc()
{
scope(failure) { writeln("What?");} // <-- never executed.
scope(failure) {
writeln("Failed in someFunc()");
return;
}
throw new Exception("Exception!");
}
void main() {
try {
someFunc();
writeln("Yay, someFunc() is nothrow");
} catch(Exception e) {
writeln("An exception in main!");
}
}
In someFunc, the first scope(failure) is never executed. There's no bug, but I
think, if -w specified, dmd should warn the code as that it is not reachable.
--
More information about the Digitalmars-d-bugs
mailing list