Solution to "statement is not reachable" depending on template variables?
tsbockman via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Mar 16 18:48:50 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.
This only works (sometimes) because D's value range propagation
doesn't understand comparisons or normal if statements very well.
This will hopefully be fixed sooner or later:
https://github.com/D-Programming-Language/dmd/pull/1913
https://github.com/D-Programming-Language/dmd/pull/5229
The only future-proof way to fix the "statement is not reachable"
warning, is to guard the potentially unreachable code with a
`static if` whose predicate precisely describes the circumstances
in which it becomes unreachable...
...Which itself is a terrible solution that doesn't scale well at
all to complex generic code and violates the "DRY" principle.
We really ought to just remove the warning. It just doesn't mesh
well with D's super-powered meta-programming features.
More information about the Digitalmars-d-learn
mailing list