www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23191] New: [dip1000] scope parameter can be returned in


          Issue ID: 23191
           Summary: [dip1000] scope parameter can be returned in  system
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: dkorpel live.nl

`scope` checks are only enabled in  safe code because they might have false
positives, and we don't want to break valid  system code, where we trust the
programmer to get it right. 

However, blatantly returning a `scope` parameter could still be made an error.
This is useful since  system is still the default and `scope` may be hidden
behind `in`.

int* f(scope int* x)
    return x;

const(int)* f(in int* x) // with -preview=in, it means `const scope`
    return x; // may look innocuous

This came up in the news group:
https://forum.dlang.org/post/t7rfdm$1jjc$1 digitalmars.com
https://forum.dlang.org/post/t88iuv$mbb$1 digitalmars.com

Jun 16 2022