www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13430] New: Improve error message with wrong arg type to

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

          Issue ID: 13430
           Summary: Improve error message with wrong arg type to inout
                    function
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: turkeyman gmail.com

This error message had me scratching my head for half an hour. Please fix this
situation to report the appropriate error.

This code produces the error:
  Error: inout method db.ui.listadapter.S.f is not callable using a mutable
object

struct S
{
    inout(int) f(int x) inout // inout method
    {
        return x;
    }
}

void f(size_t s)
{
    S x;

    // call it with the wrong type (size_t, expects int)
    x.f(s); // very surprising error message

    // call with appropriate type, no problem
    x.f(cast(int)s);
}

--
Sep 06 2014