[Issue 2288] New: Cannot mixin a case or default statement

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Aug 17 02:45:41 PDT 2008


http://d.puremagic.com/issues/show_bug.cgi?id=2288

           Summary: Cannot mixin a case or default statement
           Product: D
           Version: 1.034
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: matti.niemenmaa+dbugzilla at iki.fi


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);"
        "}");
}


-- 



More information about the Digitalmars-d-bugs mailing list