August 15, 2022 [Issue 23295] New: [dip1000] explain why scope inference failed | ||||
|---|---|---|---|---|
| ||||
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@puremagic.com Reporter: dkorpel@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` -- | ||||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply