On 10/27/15 3:50 AM, Daniel Murphy wrote:
On 25/10/2015 4:25 AM, tsbockman wrote:
///////////////////////////////
module main;
import std.stdio;
void reachIf(bool x)()
{
if(!x)
return;
writeln("reached"); // Warning: statement is not reachable
}
void main(string[] args) {
reachIf!true(); // prints "reached"
reachIf!false(); // triggers warning
}
///////////////////////////////
Thoughts?
Easy to fix:
void reachIf(bool x)()
{
static if(!x)
return;
else
writeln("reached");
}
The warning is correct, and incredibly annoying.
Easy to fix, but the warning is incorrect, the statement is reachable if
you use reachIf!true.
A statement is not a compiled piece of code.
-Steve