www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8994] New: typeof fails when passing delegate as alias parameter

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

           Summary: typeof fails when passing delegate as alias parameter
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: deadalnix gmail.com


--- Comment #0 from deadalnix <deadalnix gmail.com> 2012-11-10 10:19:48 PST ---
See code below :

class A {
    void foo() {
        new B!(a => visit(a), A)();
    }

    A visit(A a) {
        return a;
    }
}

class B(alias fun, T) {
    T t;
    typeof(fun(t)) result;
}

dmd output typeoffail.d(3): Error: need 'this' to access member visit

However, if typeof(fun(t)) result; is replaced by T result; or A result;
everything work as expected.

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


Maxim Fomin <maxim maxim-fomin.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |maxim maxim-fomin.ru


--- Comment #1 from Maxim Fomin <maxim maxim-fomin.ru> 2012-11-10 11:54:49 PST
---
This is issue 8899. Change lambda template a => visit(a) to lambda function (A
a) => visit(a) and the code compiles.

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



--- Comment #2 from deadalnix <deadalnix gmail.com> 2012-11-11 10:29:36 PST ---
(In reply to comment #1)
 This is issue 8899. Change lambda template a => visit(a) to lambda function (A
 a) => visit(a) and the code compiles.
I'm not sure at the problem trigger itself precisely when using typeof. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 11 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8994



--- Comment #3 from Maxim Fomin <maxim maxim-fomin.ru> 2012-11-11 18:25:37 PST
---
(In reply to comment #2)
 (In reply to comment #1)
 This is issue 8899. Change lambda template a => visit(a) to lambda function (A
 a) => visit(a) and the code compiles.
I'm not sure at the problem trigger itself precisely when using typeof.
I think that using lambda without parameter type is often a problem. In lucky cases there is compilation error and in worse cases this leads to mysterious bugs. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 11 2012