www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11344] New: Error: object.destroy called with argument types matches both

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

           Summary: Error: object.destroy called with argument types
                    matches both
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: rswhite4 googlemail.com


--- Comment #0 from rswhite4 googlemail.com 2013-10-24 12:58:07 PDT ---
Code:
----
import std.stdio;

struct vec2f {
public:
    float[2] values;

    alias values this;
}

struct array(T) {
public:
    T* ptr;
    size_t length;

    ~this() {
        static if (is(T == struct) || is(T == class)) {
            foreach (ref T item; this.ptr[0 .. this.length]) {
                .destroy!T(item);
            }
        }
    }
}

void main() {
    array!vec2f foo;
}
----

C:\Users\Besitzer\D\destroy_bug.d(18): Error: object.destroy called with
argument types (vec2f) matches both:
    D:\D\dmd2\windows\bin\..\..\src\druntime\import\object.di(513):
destroy(T)(ref T obj) if (is(T == struct))
and:
    D:\D\dmd2\windows\bin\..\..\src\druntime\import\object.di(524): destroy(T :
U[n], U, uint n)(ref T obj)
C:\Users\Besitzer\D\destroy_bug.d(25): Error: template instance
destroy_bug.array!(vec2f) error instantiating


Tested with the latest beta.
Worked in dmd 2.063.2

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



--- Comment #1 from rswhite4 googlemail.com 2013-10-24 13:42:23 PDT ---
I reduced it.

This code fails in dmd 2.063.2 and dmd 2.064 beta:
----
import std.stdio;

struct vec2f {
public:
    float[2] values;

    alias values this;
}

void main() {
    vec2f v;
    destroy(v);
}
----

But this fails only with 2.064 beta:
----
import std.stdio;

struct vec2f {
public:
    float[2] values;

    alias values this;
}

void main() {
    vec2f v;
    destroy!vec2f(v);
}
----

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



--- Comment #2 from rswhite4 googlemail.com 2013-10-25 02:08:16 PDT ---
Seems that there is something wrong with the array specialization.
This prints almost the same error messages:
-----
import std.stdio;

struct vec2f {
public:
    float[2] values;

    alias values this;
}

void foo(T)(ref T obj) if (is(T == struct)) {
    writeln("#1");
}

void foo(T : U[n], U, size_t n)(ref T obj) {
    writeln("#2");
}

void main() {
    vec2f v;

    foo!vec2f(v);
    foo(v);
    foo(v.values);
}
----

But this works fine:
----
import std.stdio;
import std.traits;

struct vec2f {
public:
    float[2] values;

    alias values this;
}

void foo(T)(ref T obj) if (is(T == struct)) {
    writeln("#1");
}

void foo(T)(ref T obj) if (isStaticArray!T) {
    writeln("#2");
}

void main() {
    vec2f v;

    foo!vec2f(v);
    foo(v);
    foo(v.values);
}
----

And prints the expected result:
#1
#1
#2

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


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla digitalmars.com


--- Comment #3 from Walter Bright <bugzilla digitalmars.com> 2013-10-27
23:19:22 PDT ---
https://github.com/D-Programming-Language/druntime/pull/647

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



--- Comment #4 from github-bugzilla puremagic.com 2013-10-28 12:18:46 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/druntime

https://github.com/D-Programming-Language/druntime/commit/ed48ca3ae8f54381314682c47422beea18579ecd
fix Issue 11344 - [2.064 beta] Error: object.destroy called with argument types
matches both

https://github.com/D-Programming-Language/druntime/commit/330e19d0acebbce2f35ac2d3d550a61b0252e473
Merge pull request #647 from WalterBright/fix11344

fix Issue 11344 - Error: object.destroy called with argument types matches both

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


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

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


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



--- Comment #5 from github-bugzilla puremagic.com 2013-10-28 18:33:31 PDT ---
Commit pushed to 2.064 at https://github.com/D-Programming-Language/druntime

https://github.com/D-Programming-Language/druntime/commit/906d15207000ae0194d3a7b6efa06c3ecead1ae0
Merge pull request #647 from WalterBright/fix11344

fix Issue 11344 - Error: object.destroy called with argument types matches both

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