Bug 23168 – [DIP1000] return scope wrongly rewritten for structs with no indirections

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2022-06-07T15:09:43Z
Last change time
2022-06-23T09:36:38Z
Keywords
pull
Assigned to
No Owner
Creator
Ate Eskola

Comments

Comment #0 by Ajieskola — 2022-06-07T15:09:43Z
Compile with dmd 2.100.0 and -preview=dip1000 switch. --------------- struct Ptr { @safe int* fun() return scope {return null;} //int* aRef; uncomment to compile } @safe int* use() { Ptr ptr; return ptr.fun; } --------------- The compiler detects that Ptr has no indirections, so it correctly judges `return scope` as needless. However, instead of just removing it, it replaces it with `return` attribute. This makes this code to wrongly fail to compile.
Comment #1 by dlang-bot — 2022-06-21T12:46:44Z
@dkorpel created dlang/dmd pull request #14232 "Fix 23168 - return scope wrongly rewritten for structs with no indirections" fixing this issue: - Fix 23168 - return scope wrongly rewritten for structs with no indirections https://github.com/dlang/dmd/pull/14232
Comment #2 by dlang-bot — 2022-06-23T09:36:38Z
dlang/dmd pull request #14232 "Fix 23168 - return scope wrongly rewritten for structs with no indirections" was merged into master: - 536f3eb243047a1b97df561b1353e5b073c25415 by Dennis Korpel: Fix 23168 - return scope wrongly rewritten for structs with no indirections https://github.com/dlang/dmd/pull/14232