digitalmars.D.bugs - [Issue 20362] New: dmd fails to infer scope parameter for delegate
- d-bugmail puremagic.com (33/33) Nov 06 2019 https://issues.dlang.org/show_bug.cgi?id=20362
https://issues.dlang.org/show_bug.cgi?id=20362 Issue ID: 20362 Summary: dmd fails to infer scope parameter for delegate Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: atila.neves gmail.com With dmd 2.089.0, *without* using -preview=dip1000, this fails to compile: -------------------- void stringify(scope void delegate(scope const char[]) sink) { sink("oops"); } void main() { string str; stringify((chars) {str ~= chars; }); } -------------------- bug.d(7): Error: function bug.stringify(scope void delegate(scope const(char[])) sink) is not callable using argument types (void) bug.d(7): cannot pass argument __lambda1 of type void to parameter scope void delegate(scope const(char[])) sink It compiles successfully with -preview=dip1000. A workaround is to explicitly add `scope` to the `chars` parameter of the delegate, and then it compiles with and without -preview=dip1000. This is blocking this PR: https://github.com/dlang/dmd/pull/10506 --
Nov 06 2019