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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue May 3 02:30:42 PDT 2011


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 at puremagic.com
        ReportedBy: kennytm at gmail.com


--- Comment #0 from kennytm at gmail.com 2011-05-03 02:26:41 PDT ---
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: -------


More information about the Digitalmars-d-bugs mailing list