On Wednesday, 12 June 2013 at 08:49:36 UTC, Jacob Carlborg wrote:
I'm merging the orange (std.serialization) unit tests with the test of Phobos. I hit a problem. I'm getting a warning about unreadable code but it's clear the code is reachable in some cases because there's a static-if involved. The unit tests won't run if there's a warning. How can we solve this?

The problem is that there must be a static if branch that is shortcicuiting the code, right? Eg:

unittest
{

    static if (somecondition) return;

    unreachable_code
}

The compiler error (AFAIK) for "unreachable code" is not generic to the code, but only appears for the specific types that makes the unreachable_code actually unreachable. I've hit this a couple of times in algorithm's unittests.

The workaround is usally to use static else and/or assert(0), and to make sure that regardless of types, there is never any code inserted that could be un-used.

Do you have a link to the actual problem?

Reply via email to