www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4497] New: inexpressive error message for const object method

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4497

           Summary: inexpressive error message for const object method
           Product: D
           Version: D2
          Platform: Other
        OS/Version: All
            Status: NEW
          Keywords: diagnostic
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: mrmocool gmx.de



class Foo
{
    void getX()
    {}
}

const Foo f;

void main()
{
    f.getX();
}

Error: function constobj.Foo.getX () is not callable using argument types ()
const

This error message could be more expressive to show that getX must be marked as
const to make it work.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 23 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4497




Note that this is also true for objects passed to a function as "const Class
object"

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 24 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4497


Steven Schveighoffer <schveiguy yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |schveiguy yahoo.com



06:20:03 PDT ---
I think the message is actually accurate.  I'll split out the relevant parts:

testbug.d(11): Error: function

testbug.Foo.getX ()          is not callable using argument types 
                 () const

What's happening is, the hidden this parameter is passed as const since the
object is const, but getX doesn't accept a const Foo.

It's the same as if you had a function like this:

void foo(Foo x)

foo(f);

Since f is const, and foo(Foo) must accept a mutable foo.

However, most people see the "const" applying to the function, which is a
common misconception.

I think a better error message might look like this:

Error: function constobj.Foo.getX () cannot be called using a const Foo.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 26 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4497




I'm pretty sure I also had similar errors without the indicating "const" at the
end of the message.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 03 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4497


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |andrej.mitrovich gmail.com
         Resolution|                            |DUPLICATE



13:45:34 PST ---
*** This issue has been marked as a duplicate of issue 1730 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 23 2012