case statement allows for runtime values, a case of accepts-invalid?

Jesse Phillips jessekphillips+D at gmail.com
Tue Apr 19 08:36:37 PDT 2011


Andrej Mitrovic Wrote:

> int foo(ref int y)
> {
>     y = 5;
>     return y;
> }
> 
> void main()
> {
>     int x = 1;
>     int y = 2;
>     
>     switch (x = foo(y))
>     {
>         case y:
>             writeln("x == y");
>         default:
>     }
>     
>     assert(x == 5);
>     assert(y == 5);
> }

Yes bug. Not this part though

>     switch (x = foo(y))


More information about the Digitalmars-d-learn mailing list