Comment #0 by snarwin+bugzilla — 2022-03-20T18:15:16Z
As of DMD 2.099.0, the following program fails to compile:
---
inout(int)[] fun(inout(int)[] a)
{
import core.lifetime: forward;
return forward!a;
}
---
The error message is:
---
/dlang/dmd/linux/bin64/../../src/druntime/import/core/lifetime.d(1558): Error: `inout` on `return` means `inout` must be on a parameter as well for `pure nothrow @nogc @property @safe inout(int)[]()`
onlineapp.d(4): Error: template instance `onlineapp.fun.forward!(a)` error instantiating
---
This happens because using core.lifetime.forward on a non-ref parameter creates a zero-argument nested function that returns the parameter by value.
Comment #1 by robert.schadek — 2024-12-07T13:41:53Z