www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5920] New: Cannot create std.algorithm.Array of structs with custom destructor (hasElaborateDestructor).

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

           Summary: Cannot create std.algorithm.Array of structs with
                    custom destructor (hasElaborateDestructor).
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Mac OS X
            Status: NEW
          Keywords: patch, rejects-valid
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: kennytm gmail.com



Test case:

-------------------
import std.container;
struct S {
    ~this() {}
}
alias Array!S A;
void main() {}
-------------------
/usr/include/phobos/std/container.d(1506): Error: function
std.container.Array!(S).Array.clear () is not callable using argument types (S)
/usr/include/phobos/std/container.d(1506): Error: function
std.container.Array!(S).Array.clear () is not callable using argument types (S)
/usr/include/phobos/std/container.d(1506): Error: this for clear needs to be
type Array not type Payload
/usr/include/phobos/std/container.d(1506): Error: expected 0 arguments, not 1
for non-variadic function type void()
/usr/include/phobos/std/container.d(1506): Error: cannot pass types that need
destruction as variadic arguments
-------------------

Line 1506 of std.container calls the method 'clear()' on a variable 'e', which
I think it should call the global function '.clear()' (this again shows the
name 'clear()' is bad.)

The fix is to add back the missing dot:

-------------------------------------------------
diff --git a/std/container.d b/std/container.d
index 94f6ef6..df89c2f 100755
--- a/std/container.d
+++ b/std/container.d
   -1503,7 +1503,7    struct Array(T) if (!is(T : const(bool)))
                 {
                     foreach (ref e; _payload.ptr[newLength ..
_payload.length])
                     {
-                        clear(e);
+                        .clear(e);
                     }
                 }
                 _payload = _payload.ptr[0 .. newLength];
-------------------------------------------------


Because of this bug (and issue 5792), an Array of Array cannot be created.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 03 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5920






https://github.com/D-Programming-Language/phobos/pull/35

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 03 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5920


Andrei Alexandrescu <andrei metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 03 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5920


Andrei Alexandrescu <andrei metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED



07:24:45 PDT ---
Pulled https://github.com/D-Programming-Language/phobos/pull/35. Thanks!

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