[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 13:32:15 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=10850
--- Comment #6 from Sobirari Muhomori <dfj1esp02 at sneakemail.com> ---
(In reply to timon.gehr from comment #3)
> What are you referring to? The current behaviour of DMD is indeed to
> consider 'inout' bound to the outermost inout function signature
I mean, it shouldn't work that way.
> All of these ad-hoc fixes are of a certain minimum stupidity because there
> is no right answer here (more precisely, the 'right' answer would need to
> change the surface syntax, because there would need to be more than one
> inout qualifier).
The right answer is the type system with existing syntax should be sound even
if it can be sound with different syntax.
> In any case, this suggestion (as I understand it) is indeed particularly
> stupid as it is unsound:
>
> const(int)** foo(inout(int)** x){
> // inout treated as const from nested context:
> const(int)** bar(){ return x; }
> return bar();
> }
>
> (This is the same type coercion underlying the previous proof of
> unsoundness.)
Indeed, it's a const casting and should obey const casting rules as described
in issue 4251: if conversion happens, everything beyond the first indirection
should become const. I thought, inout already takes care of that, but it
happened to be more flexible.
> > assert(foo(&a,x=>x) is &a); looks like duplicate of issue 11772 (works for
> > function, but not for delegate)
>
> If anything, then issue 11772 is the duplicate.
That issue is about discrepancy between function and delegate behavior, it has
nothing to do with inout being bound to outer function.
--
More information about the Digitalmars-d-bugs
mailing list