digitalmars.D.bugs - [Issue 20116] New: Cannot return inout return value from delegate
- d-bugmail puremagic.com (42/42) Aug 08 2019 https://issues.dlang.org/show_bug.cgi?id=20116
https://issues.dlang.org/show_bug.cgi?id=20116 Issue ID: 20116 Summary: Cannot return inout return value from delegate Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: htvennik gmail.com Template function wrapping a delegate fails when the delegate happens to return an inout type. ---- import std.traits : Parameters, ReturnType; class C { private int[] _arr; property auto arr() inout nothrow nogc safe { return _arr; } } ReturnType!DG foo(DG)(scope DG func) if (!is(ReturnType!DG == void) && 0 == Parameters!func.length) { return func(); } void main() { C c; foo(&c.arr); } ---- inout.d(51): Error: inout on return means inout must be on a parameter as well for ReturnType!(inout(int[]) delegate() inout nothrow nogc property safe)(scope DG func) inout.d(60): Error: template instance `inout.foo!(inout(int[]) delegate() inout nothrow nogc property safe)` error instantiating --
Aug 08 2019