www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2288] New: Cannot mixin a case or default statement

reply d-bugmail puremagic.com writes:
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 digitalmars.com
        ReportedBy: matti.niemenmaa+dbugzilla 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);"
        "}");
}


-- 
Aug 17 2008
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2288


Rainer Schuetze <r.sagitario gmx.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |r.sagitario gmx.de
         Resolution|                            |DUPLICATE


--- Comment #1 from Rainer Schuetze <r.sagitario gmx.de> 2009-09-07 23:16:35
PDT ---
*** This issue has been marked as a duplicate of issue 1534 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 07 2009