D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 22790 - ref-return-scope is always ref-return, scope, unless return-scope appear in that order
Summary: ref-return-scope is always ref-return, scope, unless return-scope appear in t...
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 enhancement
Assignee: No Owner
URL:
Keywords: pull, safe
Depends on:
Blocks:
 
Reported: 2022-02-19 00:49 UTC by Walter Bright
Modified: 2022-03-21 17:27 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 2022-02-19 00:49:25 UTC
The rules around does ref-return-scope mean ref-return scope or does it mean ref return-scope turned out to be confusing and intractable. So I'm changing it to:

ref-return-scope means:
    ref-return scope
unless:
    "return scope" in that order appears in the source code.

This should handle all the desired cases.

But it breaks backwards compatibility. So it'll be put behind the -preview=dip1000 switch.
Comment 1 Walter Bright 2022-02-19 00:51:28 UTC
For example:

    ref int foo(ref return scope int* p)

means "ref" and "return scope".

    ref int foo(ref scope return int* p)

means "return ref" and "scope".
Comment 2 Dlang Bot 2022-02-19 00:52:39 UTC
@WalterBright updated dlang/dmd pull request #13691 "add inferReturnScope()" fixing this issue:

- fix Issue 22790 ref-return-scope is always ref-return scope unless ref-scope appears in that order

https://github.com/dlang/dmd/pull/13691
Comment 3 Dlang Bot 2022-03-09 16:36:02 UTC
@dkorpel updated dlang/dmd pull request #13693 "Make consistent use of `STC.returnScope`" fixing this issue:

- Fix issue 20881, 22790 - make ref-return-scope consistent

https://github.com/dlang/dmd/pull/13693
Comment 4 Dlang Bot 2022-03-10 21:18:06 UTC
dlang/dmd pull request #13691 "fix Issue 22790 - ref-return-scope is always ref-return, scope, unless return-scope appear in that order " was merged into master:

- d8d378b246f37ae453ae2958f0820c91683c3a59 by Walter Bright:
  fix Issue 22790 ref-return-scope is always ref-return scope unless ref-scope appears in that order

https://github.com/dlang/dmd/pull/13691
Comment 5 Dlang Bot 2022-03-11 01:54:46 UTC
dlang/dmd pull request #13799 "Revert "fix Issue 22790 - ref-return-scope is always ref-return, scope, unless return-scope appear in that order "" was merged into master:

- 03d265c9833ab6dea8b29f12dcb073ce1ecf2d25 by Dennis:
  Revert "fix Issue 22790 ref-return-scope is always ref-return scope unless ref-scope appears in that order (#13691)"
  
  This reverts commit f4437037b1b68a9b7b9197ff7649f82f97550e86.

https://github.com/dlang/dmd/pull/13799
Comment 6 Dlang Bot 2022-03-21 17:27:31 UTC
dlang/dmd pull request #13693 "Fix issue 20881, 22790 - make ref-return-scope consistent" was merged into master:

- fce2d6529550931dc7ed35f904bbc7a6ac0cd8f0 by dkorpel:
  Fix issue 20881, 22790 - make ref-return-scope consistent

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