digitalmars.D.bugs - [Issue 22907] New: Can't use core.lifetime.forward on inout parameter
- d-bugmail puremagic.com (32/32) Mar 20 2022 https://issues.dlang.org/show_bug.cgi?id=22907
https://issues.dlang.org/show_bug.cgi?id=22907 Issue ID: 22907 Summary: Can't use core.lifetime.forward on inout parameter Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: druntime Assignee: nobody puremagic.com Reporter: snarwin+bugzilla gmail.com 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. --
Mar 20 2022