← Back to index
|
Original Bugzilla link
Bug 19742 – The compiler suggests annotating parameters with `return`, even if they are marked as `return` or `return scope` already
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2019-03-16T05:46:21Z
Last change time
2020-09-03T02:32:34Z
Assigned to
No Owner
Creator
Meta
Comments
Comment #0
by monkeyworks12 — 2019-03-16T05:46:21Z
Needle* find(Haystack, Needle)(return Haystack haystack, scope Needle needle) @safe { size_t index = -1; foreach (i, ref val; haystack) { if (val == needle) { index = i; } } if (index != -1) return &haystack[index]; //Error: returning &haystack[index] escapes a reference to parameter haystack, perhaps annotate with return else return null; } void main() @safe { int[9] haystack = [0, 10, 5, 6, 2, 3, 9, 4, 5]; int* foundVal = haystack.find(3); }
Comment #1
by pro.mathias.lang — 2020-09-03T02:32:34Z
Duplicate of 19210, which is fixed in master and will be part of DMD v2.094.0. *** This issue has been marked as a duplicate of issue 19210 ***