[Issue 4497] inexpressive error message for const object method
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Jul 26 06:20:05 PDT 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4497
Steven Schveighoffer <schveiguy at yahoo.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |schveiguy at yahoo.com
--- Comment #2 from Steven Schveighoffer <schveiguy at yahoo.com> 2010-07-26 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: -------
More information about the Digitalmars-d-bugs
mailing list