www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18712] New: bogus "switch skips declaration" error with case


          Issue ID: 18712
           Summary: bogus "switch skips declaration" error with case in
           Product: D
           Version: D2
          Hardware: All
                OS: Windows
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: r.sagitario gmx.de

With dmd master this code produces an error:

int test(int n)
        mixin("case 0:");
                int x = 1;
                return x;
        case 1:
                int y = 2;
                return y;
                return -1;

swtch.d(4): Error: switch skips declaration of variable swtch.test.x at

Workaround: move the default case before the mixin.

This was a deprecation before but went unnoticed because the code compiled with
-d as it is otherwise flooded with deprecation warnings (hint: deprecation
should either be shown just once or be disabled selectively).

Apr 02 2018