[Issue 10254] Purity correctness is broken with constructor

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jun 3 08:34:48 PDT 2013


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


Simen Kjaeraas <simen.kjaras at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |simen.kjaras at gmail.com


--- Comment #1 from Simen Kjaeraas <simen.kjaras at gmail.com> 2013-06-03 08:34:47 PDT ---
Interestingly, this fails to compile:

int a;
auto foo() pure
{
    return (){a=2;} // Error: pure function 'foo.foo.__lambda1'
                    // cannot access mutable static data 'a'
}
void main()
{
    a = 1;
    auto x = foo();
    x();
    assert(a == 1);
}

This behavior indicates to me that it is in fact A's constructor that should be
a compilation error. It is a Voldemort type anyway, so how are you ever going
to call that constructor safely?

-- 
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