[Issue 23168] New: [DIP1000] return scope wrongly rewritten for structs with no indirections
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Jun 7 15:09:43 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=23168
Issue ID: 23168
Summary: [DIP1000] return scope wrongly rewritten for structs
with no indirections
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: Ajieskola at gmail.com
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.
--
More information about the Digitalmars-d-bugs
mailing list