digitalmars.D.bugs - [Issue 18712] New: bogus "switch skips declaration" error with case
- d-bugmail puremagic.com (36/36) Apr 02 2018 https://issues.dlang.org/show_bug.cgi?id=18712
https://issues.dlang.org/show_bug.cgi?id=18712 Issue ID: 18712 Summary: bogus "switch skips declaration" error with case in mixin 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) { switch(n) { mixin("case 0:"); int x = 1; return x; case 1: int y = 2; return y; default: return -1; } } swtch.d(4): Error: switch skips declaration of variable swtch.test.x at swtch.d(7) 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