[Issue 23191] New: [dip1000] scope parameter can be returned in @system code

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jun 16 08:55:24 UTC 2022


https://issues.dlang.org/show_bug.cgi?id=23191

          Issue ID: 23191
           Summary: [dip1000] scope parameter can be returned in @system
                    code
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: dkorpel at 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

--


More information about the Digitalmars-d-bugs mailing list