Bug 22907 – Can't use core.lifetime.forward on inout parameter

Status
NEW
Severity
normal
Priority
P3
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-03-20T18:15:16Z
Last change time
2024-12-07T13:41:53Z
Assigned to
No Owner
Creator
Paul Backus
Moved to GitHub: dmd#17441 →

Comments

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
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17441 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB