www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8131] New: Delegate type inference with templates is absolutely *horrible*

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

           Summary: Delegate type inference with templates is absolutely
                    *horrible*
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: wfunction hotmail.com



The code:

    import std.range;
    void f(R)(R, void delegate(ElementType!R)) { }
    void main() { f([1], (int x) { }); }

gives:

    Error: template f does not match any function template declaration
    Error: template f(R) cannot deduce template function from argument types
!()(int[],void function(int x) pure nothrow  safe)


but it should obviously be able to infer the types...

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 21 2012
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8131




Also another issue, likely to be related:


The code

    import std.range;
    void f(R)(R, void delegate(ElementType!(R))) { }
    void main() { f([1], delegate void(x) { }); }

says

    Error: undefined identifier R, did you mean template f(R)?
    Error: ElementType!(_error_) is used as a type
    Error: template f does not match any function template declaration
    Error: template f(R) cannot deduce template function from argument types
!()(int[],void)

even though 'R' and 'ElementType' are clearly both defined.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 21 2012