[Issue 15718] New: use ref or out parameters in the anonymous method may cause error

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Feb 24 01:25:09 PST 2016


https://issues.dlang.org/show_bug.cgi?id=15718

          Issue ID: 15718
           Summary: use ref or out parameters in the anonymous method may
                    cause error
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: mzfhhhh at foxmail.com

use ref or out parameters in the anonymous method may cause error,
for example:

void delegate() test1(ref int a,ref int b,ref int c)
{                          
    return {
        a=1;
        b=2;
        c=3;         
    };
}

void delegate() test2()
{
    int i;
    int a;
    int b;
    int c;
    auto p = test1(a,b,c);
    return p;
}

void test3(void delegate() p)
{      
    int[3] arr;

    p();

    writeln(arr);//arr output: 1,2,3
}                                             

void main(string[] args)
{     
    auto p = test2();
    test3(p);
}

--


More information about the Digitalmars-d-bugs mailing list