[Issue 20362] New: dmd fails to infer scope parameter for delegate

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Nov 6 15:44:53 UTC 2019


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 at puremagic.com
          Reporter: atila.neves at 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

--


More information about the Digitalmars-d-bugs mailing list