www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11774] New: Lambda argument to templated function changes its signature forever

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

           Summary: Lambda argument to templated function changes its
                    signature forever
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: verylonglogin.reg gmail.com


--- Comment #0 from Denis Shelomovskij <verylonglogin.reg gmail.com> 2013-12-19
18:53:48 MSK ---
This code should compile:
---
void f(T, R)(R delegate(T[]) del)
{
    T[] src;
    del(src);
}

void main()
{
    int[] delegate(int[]) del;
    f!int(del); // ok
    f!Object(a => a);
    f!int(del); // fails, line 12
}
---
main.d(12): Error: template main.f does not match any function template
declaration. Candidates are:
main.d(1):        main.f(T, R)(R delegate(Object[]) del)
main.d(12): Error: template main.f(T, R)(R delegate(Object[]) del) cannot
deduce template function from argument types !(int)(int[] delegate(int[]))
---

The issue is major as compiler errors are misleading and people don't expect
such "broken forever" behaviour.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 19 2013
parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11774



--- Comment #1 from Denis Shelomovskij <verylonglogin.reg gmail.com> 2013-12-19
18:55:27 MSK ---
Workaround:
Specify lambda argument types, i.e. `(Object[] a) => a` instead of `a => a`.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 19 2013