[Issue 21286] New: [DIP1000] Can't return scope reference from a function
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Sep 30 17:36:06 UTC 2020
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 at puremagic.com
Reporter: snarwin+bugzilla at 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.
--
More information about the Digitalmars-d-bugs
mailing list