D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 22108 - DIP1000 parameter mistakenly interpreted as return scope instead of scope
Summary: DIP1000 parameter mistakenly interpreted as return scope instead of scope
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords: pull, safe
Depends on:
Blocks:
 
Reported: 2021-07-07 01:34 UTC by Walter Bright
Modified: 2022-05-17 19:53 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Walter Bright 2021-07-07 01:34:27 UTC
This should fail to compile with dip1000:

  ref int test(ref scope return int* p)
  {
     return *p;
  }

p should be 'return ref` and `scope`, but the compiler interprets it as `ref` and `return scope` and passes it.
Comment 1 Dlang Bot 2021-07-07 01:36:29 UTC
@WalterBright updated dlang/dmd pull request #12817 "fix Issue 21868 - DIP1000 doesn't catch pointer to struct temporary" fixing this issue:

- fix Issue 22108 - DIP1000 parameter mistakenly interpreted as return scope instead of scope

https://github.com/dlang/dmd/pull/12817
Comment 2 Walter Bright 2022-02-18 23:21:22 UTC
What's happening is the value of p is being returned, and `return ref` and `scope` should prevent the value of p being returned.
Comment 3 Dlang Bot 2022-05-17 19:53:50 UTC
dlang/dmd pull request #12817 "fix Issue 22108 - parameter mistakenly interpreted as return scope instead of scope" was merged into master:

- 815570c3e6085e9b062e1bf57c8951a734de166b by Walter Bright:
  fix Issue 22108 - DIP1000 parameter mistakenly interpreted as return scope instead of scope

https://github.com/dlang/dmd/pull/12817