digitalmars.D.bugs - [Issue 21286] New: [DIP1000] Can't return scope reference from a
- d-bugmail puremagic.com (29/29) Sep 30 2020 https://issues.dlang.org/show_bug.cgi?id=21286
https://issues.dlang.org/show_bug.cgi?id=21286 Issue ID: 21286 Summary: [DIP1000] Can't return scope reference from a function Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: enhancement Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: snarwin+bugzilla gmail.com The following program fails to compile with -preview=dip1000: --- void main() safe { int[3] a = [1, 2, 3]; int[] slice; // ok slice = a[]; scope ref getSlice() { return slice; } // Error: reference to local variable a assigned to non-scope getSlice() getSlice() = a[]; } --- It should be possible for getSlice to return a reference that `a[]` can be safely assigned to. --
Sep 30 2020