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


--- Comment #0 from SHOO <zan77137 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: -------
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


--- Comment #1 from Simen Kjaeraas <simen.kjaras 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: -------
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


--- Comment #2 from Kenji Hara <k.hara.pg gmail.com> 2013-06-05 02:25:08 PDT ---
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



--- Comment #3 from github-bugzilla puremagic.com 2013-06-05 10:37:12 PDT ---
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



--- Comment #4 from github-bugzilla puremagic.com 2013-06-27 18:53:28 PDT ---
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



--- Comment #5 from github-bugzilla puremagic.com 2013-07-02 08:07:10 PDT ---
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
Merge pull request #2135 from 9rnsr/fix10254

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



--- Comment #6 from Kenji Hara <k.hara.pg gmail.com> 2013-07-13 23:52:46 PDT ---
*** 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