void main(string[] args)
{
    int a = 1;
    int b = to!int(args[1]);
    uint c = 2;

    switch (a)
    {
        case b: break; // OK
case c: break; // Error: variable c cannot be read at compile time

        default: break;
    }
}

Switch spec says:
The case expressions must all evaluate to a constant value or array, or a runtime initialized const or immutable variable of integral type. They must be implicitly convertible to the type of the switch Expression.

So, should the case b compile or not ? Is the spec too restrictive here, or is it a bug ?

I was initially working to fix the case c (to allow casts), but this should be clarified.

Reply via email to