www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2778] New: alias this + IFTI doesn't work.

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

           Summary: alias this + IFTI doesn't work.
           Product: D
           Version: 2.027
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: dsimcha yahoo.com


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);
}


-- 
Apr 01 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2778


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch



http://d.puremagic.com/issues/show_bug.cgi?id=2778

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


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich gmail.com



*** Issue 6569 has been marked as a duplicate of this issue. ***

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




08:46:32 PDT ---

 http://d.puremagic.com/issues/show_bug.cgi?id=2778
Nice reference :) Think you meant: https://github.com/D-Programming-Language/dmd/pull/472 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 24 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2778


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED



00:22:11 PDT ---
https://github.com/D-Programming-Language/dmd/commit/35ee32cafe1cfb606e1d511807206829f8ed5855

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


Kenji Hara <k.hara.pg gmail.com> changed:

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



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

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


Kenji Hara <k.hara.pg gmail.com> changed:

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



https://github.com/D-Programming-Language/dmd/commit/01ba9d230205c10909a021787f00f741ee511e01

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