https://issues.dlang.org/show_bug.cgi?id=18146
Nick Treleaven <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] --- Comment #4 from Nick Treleaven <[email protected]> --- The problem in comment #3 seems to be these lines: class Bezier(BezierOrder TYP){ enum ubyte N= cast(ubyte)TYP+1u; typeof(this)[2] offsetCurve(in double width) @safe const do{ final switch(TYP){ case BezierOrder.Line: static assert(N == 2u); // compile-time error is generated here break; case BezierOrder.Quadratic: static assert(N == 3u); *All* the code inside `final switch` will be *compiled* regardless of the value of `TYP`. `final switch` works at runtime even when given a compile-time argument. So the compiler will try to compile *both* `static asserts` in the `final switch`. > In order to avoid the problem, I tried to use static if statements instead of > a final switch statement. Yes, because `static if` branches are only compiled if the compile-time condition is true. --
