[Issue 10850] Inout substituted incorrectly for delegates/fptrs in inout function signature

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat Sep 13 10:20:14 PDT 2014


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

--- Comment #2 from Sobirari Muhomori <dfj1esp02 at sneakemail.com> ---
(In reply to timon.gehr from comment #0)
> git head:
> 
> Since apparently inout now refers to the outermost inout function

What? How? That looks incorrect. inout should be applied to data passed to the
inout function, not to delegate signatures, those are independent.

> 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;
> }

If one wants a really really stupid fix for nested inout functions, then inout
data outside of the nested function should be treated as const.

> immutable(int) x;
> static assert(is(typeof(foo(x))==immutable(int)* delegate(immutable(int)*)));

I'd say, the return type should be inout delegate, converting it to immutable
is possible, but unnecessarily restrictive.


assert(foo(&a,x=>x) is &a); looks like duplicate of issue 11772 (works for
function, but not for delegate)

--


More information about the Digitalmars-d-bugs mailing list