digitalmars.D.bugs - [Issue 20245] New: DIP1000: Should infer scope when taking address
- d-bugmail puremagic.com (32/32) Sep 25 2019 https://issues.dlang.org/show_bug.cgi?id=20245
https://issues.dlang.org/show_bug.cgi?id=20245 Issue ID: 20245 Summary: DIP1000: Should infer scope when taking address of ref Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: bugzilla digitalmars.com For -preview=dip1000 : safe int* foo(ref int x) { int* a = &x; return a; } This should infer `scope` for `a`, and then issue an error on returning `a`. The following should not compile: safe int** foo(ref scope int* x) { int** a = &x; return a; } because there's not way to attach `scope` to anything but the head, i.e. no scope pointers to scope pointers to int. This should compile successfully: safe int* foo(return ref int x) { int* a = &x; return a; } --
Sep 25 2019