[Issue 17477] New: DMD error message for delegate with wrong attributes is very confusing

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Jun 7 15:07:12 PDT 2017


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

          Issue ID: 17477
           Summary: DMD error message for delegate with wrong attributes
                    is very confusing
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: eyal at weka.io

When compiling this invalid program:

void f(void delegate(int) nothrow dlg) {}

void main() {
    void g(int x) {}
    f((x){ g(x); });
}

The error reported is:

Error: function f (void delegate(int) nothrow dlg) is not callable using
argument types (void)

This is wrong, as the argument type is not (void). It is also very difficult to
figure out what is wrong with this program from this error (when the code is
far more complicated).

A better error would be:

Error: function f expects (void delegate(int) **nothrow** dlg) but was given
(void delegate(int))

--


More information about the Digitalmars-d-bugs mailing list