[Issue 15651] filter: only parameters or stack based variables can be inout

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Aug 16 12:17:46 UTC 2019


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

Simen Kjaeraas <simen.kjaras at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |simen.kjaras at gmail.com
          Component|dmd                         |phobos

--- Comment #1 from Simen Kjaeraas <simen.kjaras at gmail.com> ---
This issue is only partially fixable - filter() could use the solution
described in issue 13428 to turn inout(T) into const(T). This would lead to
fun() returning a const(D)[] result instead of inout(D)[], so it's not a
complete solution.

A complete solution, in fact, is not actually possible - consider the case of
returning SomeStruct!(inout(D)). inout(D) is only a valid type inside the inout
function - after returning, inout(D) should turn into D, const(D), or
immutable(D). That means SomeStruct!(inout(D)) should turn into
SomeStruct!(const(D)) or one of the other constancy variations, and this type
might be completely different from SomeStruct!(inout(D)), due to the way D's
templates work. Perhaps a solution could be found to this problem, but it would
very likely require a DIP.

--


More information about the Digitalmars-d-bugs mailing list