[Issue 23295] New: [dip1000] explain why scope inference failed
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Aug 15 13:11:48 UTC 2022
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: nobody at puremagic.com
Reporter: dkorpel at live.nl
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`
--
More information about the Digitalmars-d-bugs
mailing list