[Issue 10254] New: Purity correctness is broken with constructor

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jun 3 07:57:25 PDT 2013


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

           Summary: Purity correctness is broken with constructor
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: zan77137 at nifty.com


--- Comment #0 from SHOO <zan77137 at nifty.com> 2013-06-03 07:57:24 PDT ---
This code doesn't work:
---------------
int a;
auto foo() pure
{
    static class A { this(){a = 2;} }
    return new A; // This line should be a compilation error.
}
void main()
{
    a = 1;
    auto x = foo(); // Pure function doesn't change any global variables.
    assert(a == 1); // Thefore, global variable `a` never changes.
}

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


More information about the Digitalmars-d-bugs mailing list