Bug 11344 – [2.064 beta] Error: object.destroy called with argument types matches both

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-10-24T12:58:00Z
Last change time
2013-10-28T18:33:31Z
Assigned to
nobody
Creator
rswhite4

Comments

Comment #0 by rswhite4 — 2013-10-24T12:58:07Z
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
Comment #1 by rswhite4 — 2013-10-24T13:42:23Z
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); } ----
Comment #2 by rswhite4 — 2013-10-25T02:08:16Z
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
Comment #3 by bugzilla — 2013-10-27T23:19:22Z
Comment #4 by github-bugzilla — 2013-10-28T12:18:46Z
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
Comment #5 by github-bugzilla — 2013-10-28T18:33:31Z
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