Bug 22910 – [dip1000] return scope struct member functions allow returning `this` by ref

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-03-22T15:13:33Z
Last change time
2022-03-23T12:17:33Z
Keywords
pull, safe
Assigned to
No Owner
Creator
Dennis

Comments

Comment #0 by dkorpel — 2022-03-22T15:13:33Z
This should give an error since the function is `return scope`, while it should be `return ref` for returning a reference to `this`: ``` struct S { int val; int* ptr; int* retScope() return scope { return &this.val; } } ```
Comment #1 by dlang-bot — 2022-03-22T16:35:52Z
@dkorpel created dlang/dmd pull request #13860 "Fix issue 22910 - `return scope` struct member functions allow returning `this` by ref" fixing this issue: - Fix issue 22910 - `return scope` struct member functions allow returning `this` by ref https://github.com/dlang/dmd/pull/13860
Comment #2 by dlang-bot — 2022-03-23T12:17:33Z
dlang/dmd pull request #13860 "Fix issue 22910 - `return scope` struct member functions allow returning `this` by ref" was merged into master: - 31f410b04fde66afadebf6ae2da289b37ef626d7 by Dennis Korpel: Fix issue 22910 - `return scope` struct member functions allow returning `this` by ref https://github.com/dlang/dmd/pull/13860