[Issue 14846] New: Insufficient context deduction with implicit nested lambda

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Jul 28 21:46:27 PDT 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 at puremagic.com
          Reporter: k.hara.pg at 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)]; });
}

--


More information about the Digitalmars-d-bugs mailing list