digitalmars.D.bugs - [Issue 19742] New: The compiler suggests annotating parameters with
- d-bugmail puremagic.com (38/38) Mar 15 2019 https://issues.dlang.org/show_bug.cgi?id=19742
https://issues.dlang.org/show_bug.cgi?id=19742 Issue ID: 19742 Summary: The compiler suggests annotating parameters with `return`, even if they are marked as `return` or `return scope` already Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: monkeyworks12 hotmail.com 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); } --
Mar 15 2019