www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10850] New: Inout substituted incorrectly for delegates in inout function signature

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

           Summary: Inout substituted incorrectly for delegates in inout
                    function signature
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: timon.gehr gmx.ch



git head:

Since apparently inout now refers to the outermost inout function, inout should
also be substituted for delegates inside the function signature:

inout(int)* delegate(inout(int)*) foo(ref inout(int) x){
    inout(int)* bar(inout(int)*) { return &x; }
    return &bar;
}
immutable(int) x;
static assert(is(typeof(foo(x))==immutable(int)* delegate(immutable(int)*)));

(Also note that none of the recent language updates towards type safe inout
checking were documented.)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 19 2013
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10850


timon.gehr gmx.ch changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Inout substituted           |Inout substituted
                   |incorrectly for delegates   |incorrectly for
                   |in inout function signature |delegates/fptrs in inout
                   |                            |function signature



Other test case:

inout(int)* foo(inout(int)* a, inout(int)* delegate(inout(int)*) dg){
    return dg(a);
}
inout(int)* bar(inout(int)* a, inout(int)* delegate(inout(int)*) dg){
    auto x = dg(a);
    int* y;
    dg(y);
    return x;
}    
void main(){
    immutable int a;
    assert(foo(&a,x=>x) is &a); // error
    static assert(is(typeof(foo(&a,x=>x))==immutable(int)*)); // error
    assert(foo(&a,(immutable(int)* x)=>x) is &a); // error
}

This should compile.

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