[Issue 20156] [REG2.080] Wrong error about local variable escape

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Mar 24 11:27:30 UTC 2022


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

Dennis <dkorpel at live.nl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dkorpel at live.nl

--- Comment #3 from Dennis <dkorpel at live.nl> ---
This is 'fixed' because `inout` doesn't imply `return` anymore (issue 22027).

If you change the function signature to this:
```
inout(int[]) f1(return ref inout A);
```
The error is back when you pass -preview=dip1000, but it's valid, because the
return value can be a pointer to the struct A which is allocated on the stack
in f2, and you can't store a stack pointer in a dynamic array.

If f1 becomes this (which is likely what the function should be, judging by the
types):
```
inout(int[]) f1(ref return scope inout A);
```
Then there's no error, which is correct because local var c is not `scope`.
Either way, it's fixed now.

--


More information about the Digitalmars-d-bugs mailing list