Two Scala annotations

Walter Bright newshound2 at digitalmars.com
Sat Jun 30 17:33:16 PDT 2012


On 5/27/2012 6:13 AM, bearophile wrote:
> Currently this D2 code compiles:
>
> void main() {
>      int x = 2;
>      int y = 2;
>      switch(x) {
>          case 1: break;
>          case y: break;
>          default:
>      }
> }
>
> I think that accepting that "case y" is a compiler bug, because y is a run-time
> value, that kills some switch optimization possibilities.

It's not a bug. It's deliberate, and is there to support mechanical translation 
of Java code.


More information about the Digitalmars-d mailing list