July 29, 2015
https://issues.dlang.org/show_bug.cgi?id=14846

          Issue ID: 14846
           Summary: Insufficient context deduction with implicit nested
                    lambda
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody@puremagic.com
          Reporter: k.hara.pg@gmail.com

Test case:

void foo(Dg)(scope Dg code)
{
    pragma(msg, Dg);
    // Now Dg is deduced to 'void function()',
    // but it should be 'void delegate()'.

    code();
}

void main()
{
    int x;

    struct S
    {
        this(int n) { x = n; }
        ~this() { x = 99; }
    }

    foo({ S s; });
    foo({ S s = S(); });
    foo({ S s = S(1); });
    foo({ S[3] s; });

    foo({ S* p = new S(); });
    foo({ S* p = new S(1); });
    foo({ S[] a = [S()]; });
    foo({ S[] a = [S(1)]; });
}

--