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



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



---
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





 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




---


 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