October 06, 2014 [Issue 13575] New: Unreachable scope(failure) should be warned | ||||
---|---|---|---|---|
| ||||
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@puremagic.com Reporter: k.hara.pg@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. -- |
Copyright © 1999-2021 by the D Language Foundation