[Issue 18712] New: bogus "switch skips declaration" error with case in mixin
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Apr 3 06:34:39 UTC 2018
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 at puremagic.com
Reporter: r.sagitario at 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).
--
More information about the Digitalmars-d-bugs
mailing list