www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10254] New: Purity correctness is broken with constructor

reply d-bugmail puremagic.com writes:
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 puremagic.com
        ReportedBy: zan77137 nifty.com



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: -------
Jun 03 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10254


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

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



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: -------
Jun 03 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10254


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid, pull



https://github.com/D-Programming-Language/dmd/pull/2135

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 05 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10254




Commit pushed to master at https://github.com/D-Programming-Language/druntime

https://github.com/D-Programming-Language/druntime/commit/e1cbd173bc1bdaa62a584f22df4cba7e3ba1ec8f
Change the Exception/Error constructors to  safe pure nothrow

This is a druntime fix-up for the compiler bug 10254.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 05 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10254




Commit pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/92bef24f2f94c26db28d22a2ee73f4061e3d476e
fix Issue 10254 - Purity correctness is broken with constructor

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 27 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10254




Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/6e6310d20dfa75c1d56b33be66056e9554092e0c
fix Issue 10254 - Purity correctness is broken with constructor

https://github.com/D-Programming-Language/dmd/commit/64e05bb8862c1cd33d61900957dc128d1c8d4712


Issue 10254 - Purity correctness is broken with constructor

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 02 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10254


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |yebblies gmail.com
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 02 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10254




*** Issue 6320 has been marked as a duplicate of this issue. ***

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