[Issue 23491] New: Nonsensical deprecation message when using delegate
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Nov 17 09:38:15 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=23491
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 at puremagic.com
Reporter: pro.mathias.lang at gmail.com
Code:
```
import core.internal.string : unsignedToTempString;
void main () @safe
{
toString(null);
}
void toString (void delegate (char[]) @safe sink) @safe
{
char[20] buffer = void;
sink(unsignedToTempString(42, buffer));
}
```
Message:
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
scope.
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;
--
More information about the Digitalmars-d-bugs
mailing list