D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 22967 - [dip1000] no return ref inference for extended return semantics
Summary: [dip1000] no return ref inference for extended return semantics
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Windows
: P1 enhancement
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2022-04-02 14:18 UTC by Dennis
Modified: 2022-04-06 07:22 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 Dennis 2022-04-02 14:18:39 UTC
When returning a parameter by assignment to the first ref parameter, return scope can be inferred when it's a template/auto function. This is not the case for return ref yet:
```
@safe:   
struct S()
{
    int* x;
    this(scope int* x) { this.x = x; } // return scope inferred
    this(ref int x) { this.x = &x; } // no return ref inferred, error
}

void main()
{
    S!() s;
}
```
Comment 1 Dlang Bot 2022-04-05 15:13:14 UTC
@dkorpel created dlang/dmd pull request #13952 "Fix issue 22967 - no `return ref` inference for extended return semantics" fixing this issue:

- Fix issue 22967 - no return ref inference for extended return semantics

https://github.com/dlang/dmd/pull/13952
Comment 2 Dlang Bot 2022-04-06 07:22:27 UTC
dlang/dmd pull request #13952 "Fix issue 22967 - no `return ref` inference for extended return semantics" was merged into master:

- 13012b879016b03c3d1ff367a860e9f3bf70421a by Dennis Korpel:
  Fix issue 22967 - no return ref inference for extended return semantics

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