www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5121] New: Make std.algorithm.swap weakly pure

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5121

           Summary: Make std.algorithm.swap weakly pure
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: patch
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



This is a test program that fails with dmd 2.050alpha:


import std.algorithm: swap;
pure int foo(int x, int y) {
    swap(x, y);
    return y;
}
void main() {
    assert(foo(10, 20) == 10);
}


But swap may be modified to become weakly pure, just changing this line 1063:

void swap(T)(ref T a, ref T b) if (!is(typeof(T.init.proxySwap(T.init))))


Into:

pure void swap(T)(ref T a, ref T b) if (!is(typeof(T.init.proxySwap(T.init))))


(Probably several other functions in Phobos may now be tagged was (weakly)
pure.)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 26 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5121




See:
http://www.dsource.org/projects/phobos/changeset/2180

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 19 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5121


yebblies <yebblies gmail.com> changed:

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



This code now compiles with the new purity inference in dmd 2.054 (or was it
the phobos changes?)
Either way, fixed.

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