Solution to "statement is not reachable" depending on template variables?

Johan Engelen via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Mar 16 10:05:03 PDT 2016


On Wednesday, 16 March 2016 at 11:22:02 UTC, rikki cattermole 
wrote:
>
> Change those static if's to just plain old ifs.

But then this wouldn't compile, would it?
```
static if(__traits(compiles, __traits(getMember, a, "b"))) {
    return a.b;
}
```
(real code, I am not making this up)

> Imagine those foreach loops being unrolled and what that 
> happens there isn't just one return there, imagine many many 
> many of them and all of them valid.

Yep :-)

Perhaps the only solution is to be able to annotate the code to 
"shut up" DMD about it.


More information about the Digitalmars-d-learn mailing list