Bug 2288 – Cannot mixin a case or default statement

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D1 (retired)
Platform
All
OS
All
Creation time
2008-08-17T04:45:00Z
Last change time
2014-03-01T00:36:52Z
Keywords
rejects-valid
Assigned to
nobody
Creator
matti.niemenmaa+dbugzilla

Comments

Comment #0 by matti.niemenmaa+dbugzilla — 2008-08-17T04:45:40Z
void main() { switch (0) { mixin ("case 0: break;"); default: assert (0); } } The above code fails to compile with repeated "found 'EOF' instead of statement" errors on the line of the mixin, as does the following: void main() { switch (0) { mixin ("default: break;"); } } Were they not mixins, the code would compile and run fine. Mixing in ordinary labelled statements works: void main() { goto x; assert (0); mixin("x:;"); } Workarounds: Mixing in the entire switch statement: void main() { mixin("switch (0) {" "case 0: break;" "default: assert (0);" "}"); } Or just the block statement inside the switch: void main() { switch (0) mixin("{" "case 0: break;" "default: assert (0);" "}"); }
Comment #1 by r.sagitario — 2009-09-07T23:16:35Z
*** This issue has been marked as a duplicate of issue 1534 ***