https://issues.dlang.org/show_bug.cgi?id=23295
Issue ID: 23295
Summary: [dip1000] explain why scope inference failed
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: [email protected]
Reporter: [email protected]
This comes up a lot in Phobos when using range functions (e.g. `reduce` or
`format`) that have a lot of overloads and design by introspection complexity,
making the source of scope errors really hard to track down.
Minimized example:
```
@safe:
void main()
{
scope int* x;
foo(x, null);
}
auto foo(int* y, int** w)
{
fooImpl(y, null);
}
auto fooImpl(int* z, int** w)
{
// <tons of code>
auto f = &z;
// <tons of code>
}
```
The error is:
> Error: scope variable `x` assigned to non-scope parameter `y` calling
> onlineapp.foo
It doesn't tell you anything more than that, I would like the error to tell me:
> Error: scope variable `x` assigned to non-scope parameter `y`
> which is assigned to non-scope parameter `z`
> which is not inferred `scope` because `&z`
--