[Issue 20245] New: DIP1000: Should infer scope when taking address of ref

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Sep 26 06:37:35 UTC 2019


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 at puremagic.com
          Reporter: bugzilla at 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;
     }

--


More information about the Digitalmars-d-bugs mailing list