Bug 23191 – [dip1000] scope parameter can be returned in @system code
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-06-16T08:55:24Z
Last change time
2022-06-16T10:06:54Z
Keywords
pull
Assigned to
No Owner
Creator
Dennis
Comments
Comment #0 by dkorpel — 2022-06-16T08:55:24Z
`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/[email protected]https://forum.dlang.org/post/[email protected]
Comment #1 by dlang-bot — 2022-06-16T08:58:20Z
@dkorpel created dlang/dmd pull request #14221 "Fix 23191 - scope parameter can be returned in `@system` code" fixing this issue:
- Fix 23191 - scope parameter can be returned in `@system` code
https://github.com/dlang/dmd/pull/14221
Comment #2 by dlang-bot — 2022-06-16T10:06:54Z
dlang/dmd pull request #14221 "Fix 23191 - scope parameter can be returned in `@system` code" was merged into master:
- d72e596128d4fc0ab928e3e86520e7d2fa54d14a by Dennis Korpel:
Fix 23191 - scope parameter can be returned in `@system` code
https://github.com/dlang/dmd/pull/14221