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
Note: the code was taken out of context, but the reason it's *really* important is that it occurs in Throwable.toString
@atilaneves updated dlang/dmd pull request #10506 "WIP (do not merge): Make `in` mean `scope const` in DIP1000" mentioning this issue: - Non hacky way to get around issue 20362 https://github.com/dlang/dmd/pull/10506
@atilaneves created dlang/dmd pull request #10764 "Fix issue 20362 - always infer scope for lambdas" fixing this issue: - Fix issue 20362 - always infer scope for lambdas Before, scope was only inferred if -preview=dip1000 was used, now it always is. https://github.com/dlang/dmd/pull/10764
dlang/dmd pull request #10764 "Fix issue 20362 - always infer scope for lambdas" was merged into master: - ac32a33c1dfdeec2b24dda175cbb1fe87778c012 by Atila Neves: Fix issue 20362 - always infer scope for lambdas Before, scope was only inferred if -preview=dip1000 was used, now it always is. https://github.com/dlang/dmd/pull/10764