www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21348] New: Nested function can't return inout without inout

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

          Issue ID: 21348
           Summary: Nested function can't return inout without inout
                    parameter
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: snarwin+bugzilla gmail.com

Example program:

---
struct S { int i; }

inout(S) fun(inout(int) i)
{
    auto nested() { return inout(S)(i); }
    return nested();
}
---

Compiler output from DMD 2.094.0:

---
$ dmd -c bug.d 
bug.d(5): Error: inout on return means inout must be on a parameter as well for
pure nothrow  nogc  safe inout(S)()
---

--
Oct 28 2020