www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23491] New: Nonsensical deprecation message when using delegate


          Issue ID: 23491
           Summary: Nonsensical deprecation message when using delegate
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: pro.mathias.lang gmail.com

import core.internal.string : unsignedToTempString;
void main ()  safe
void toString (void delegate (char[])  safe sink)  safe
    char[20] buffer = void;
    sink(unsignedToTempString(42, buffer));


foo.d(9): Deprecation: reference to local variable `buffer` assigned to
non-scope parameter `__anonymous_param` calling ``

The actual problem is that the return value of `unsignedToTempString`, which is
a slice of `buffer`, is passed to the first argument of `sink` that is not
However, the message:
1) Doesn't name `sink` at all (The '``' is obviously a bug);
2) References `buffer` but not the return value of `unsignedToTempString`;
3) Doesn't handle anonymous params gracefully;

Nov 17 2022