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

           Summary: Nested lambda inference doesn't work
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nob...@puremagic.com
        ReportedBy: k.hara...@gmail.com


--- Comment #0 from Kenji Hara <k.hara...@gmail.com> 2012-06-04 20:56:30 PDT ---
Following code should work, but doesn't.

void main()
{
    T delegate(T) zero(T)(T delegate(T) f)
    {
        return x => x;
    }

    T delegate(T) delegate(T delegate(T)) succ(T)(T delegate(T) delegate(T
delegate(T)) n)
    {
        return f => x => f(n(f)(x));    // Line 10
// test.d(10): Error: function has no effect in expression (__lambda6)
// test.d(10): Error: template instance
test.main.succ!(uint).succ.__lambda4!(uint delegate(uint)) error instantiating
// test.d(21):        instantiated from here: succ!(uint)
// test.d(21): Error: template instance test.main.succ!(uint) error
instantiating
    }

    auto n = &zero!uint;
    foreach (i; 0..10)
    {
        assert(n(x => x + 1)(0) == 1);
        n = succ(n);                    // Line 21
    }
}

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

Reply via email to