Bug 2778 – alias this + IFTI doesn't work.

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2009-04-01T12:03:00Z
Last change time
2015-06-09T01:18:03Z
Keywords
patch, rejects-valid
Assigned to
nobody
Creator
dsimcha

Comments

Comment #0 by dsimcha — 2009-04-01T12:03:38Z
DMD 2.027 can't implicitly instantiate templates properly based on implicit conversions via alias this. import std.stdio; struct ArrayWrapper(T) { T[] data; alias data this; } void doStuffTempl(T)(T[] data) {} void doStuffFunc(int[] data) {} void main() { ArrayWrapper!(int) foo; doStuffFunc(foo); // Works. doStuffTempl!(int)(foo); // Works. // Error: template test.doStuffTempl(T) does not match any function // template declaration // Error: template test.doStuffTempl(T) cannot deduce // template function from argument types !()(ArrayWrapper!(int)) doStuffTempl(foo); }
Comment #1 by k.hara.pg — 2011-10-23T09:17:05Z
Comment #2 by k.hara.pg — 2011-10-23T22:46:19Z
*** Issue 6569 has been marked as a duplicate of this issue. ***
Comment #3 by schveiguy — 2011-10-24T08:46:32Z
Comment #4 by bugzilla — 2011-11-02T00:22:11Z
Comment #5 by k.hara.pg — 2011-11-02T04:47:30Z
I found a lack of my patch. Code: ---- inout(T) [n] id(T, size_t n)(inout(T) [n] v){ return v; } void main() { static struct S { ubyte[3] val = [1,2,3]; @property ref void[3] get(){ return *cast(void[3]*)&val; } alias get this; } S s; id(s); } Output: ---- test.d(18): Error: template test.id(T,uint n) does not match any function template declaration test.d(18): Error: template test.id(T,uint n) cannot deduce template function from argument types !()(S) Additional patch for repair it: https://github.com/D-Programming-Language/dmd/pull/487
Comment #6 by k.hara.pg — 2011-12-20T22:08:57Z