www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20491] New: extern(C) is not inferred for lambda agruments

https://issues.dlang.org/show_bug.cgi?id=20491

          Issue ID: 20491
           Summary: extern(C) is not inferred for lambda agruments
           Product: D
           Version: D2
          Hardware: All
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: maxsamukha gmail.com

extern(C++) alias F = void function();
void foo(F f) {
}

void bar(void function() f) {
}

void main() {
    F f = () {}; // ok
    bar(() {}); // ok without extern(C);
    foo(() {}); // fail
}

onlineapp.d(12): Error: function onlineapp.foo(extern (C++) void function() f)
is not callable using argument types (void function() pure nothrow  nogc  safe)
onlineapp.d(12):        cannot pass argument __funcliteral3 of type void
function() pure nothrow  nogc  safe to parameter extern (C++) void function() f

Same for extern(C++).

--
Jan 08 2020