digitalmars.D - Statement is unreachable error
- deadalnix (21/21) Jun 03 2013 I reach this error all the time. When debugging for instance, I
- Andrej Mitrovic (4/6) Jun 03 2013 I have the same problem, sometimes for testing purposes (exactly
- John Colvin (3/9) Jun 03 2013 It would be nice to have a compiler switch that turns off these
- monarch_dodra (15/27) Jun 03 2013 One of the problem's _I_ have been able to observe, and which is
I reach this error all the time. When debugging for instance, I may want to stick a throw in the middle of some code, or whatever, and get into it, have to go back to the code, comment bunch of stuff, go back to compile. This is something that is obviously important to have, but I think to have it by default is really annoying. In addition, it tends to kick in when using static if. See sample code below : uint foo() { static if(condition) { return 0; } // Do some computation. return value; } Now, if you want that piece of code to compile, you got to stick the whole function body into an else, and it really make the code unreadable sometime when you got static ifs within other static ifs. Can we at least disable the feature for termination of control flow that belongs to different compile time scope ?
Jun 03 2013
On Monday, 3 June 2013 at 14:53:23 UTC, deadalnix wrote:I reach this error all the time. When debugging for instance, I may want to stick a throw in the middle of some codeI have the same problem, sometimes for testing purposes (exactly for debugging) I'd like to return early or throw, but then I get compiler errors.
Jun 03 2013
On Monday, 3 June 2013 at 14:57:13 UTC, Andrej Mitrovic wrote:On Monday, 3 June 2013 at 14:53:23 UTC, deadalnix wrote:It would be nice to have a compiler switch that turns off these errors.I reach this error all the time. When debugging for instance, I may want to stick a throw in the middle of some codeI have the same problem, sometimes for testing purposes (exactly for debugging) I'd like to return early or throw, but then I get compiler errors.
Jun 03 2013
On Monday, 3 June 2013 at 15:21:15 UTC, John Colvin wrote:On Monday, 3 June 2013 at 14:57:13 UTC, Andrej Mitrovic wrote:One of the problem's _I_ have been able to observe, and which is particularly problematic (IMO), is when it happens only in release. For example: foreach(e; range) if(e==1) return 1; return 0; Imagine now "range" happens to be an infinite range. Now, return 0 will never be reached. Unfortunately, the compiler only sees this in release. This makes unittesting problematic, since there have been a few observed cases of unittests that passed, but would have failed to compile in a production environment.On Monday, 3 June 2013 at 14:53:23 UTC, deadalnix wrote:It would be nice to have a compiler switch that turns off these errors.I reach this error all the time. When debugging for instance, I may want to stick a throw in the middle of some codeI have the same problem, sometimes for testing purposes (exactly for debugging) I'd like to return early or throw, but then I get compiler errors.
Jun 03 2013