Bug 9132 – Unhelpful error message when calling non-const property from const method.
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-12-10T01:14:00Z
Last change time
2012-12-10T08:58:41Z
Keywords
diagnostic
Assigned to
nobody
Creator
bugzilla
Comments
Comment #0 by bugzilla — 2012-12-10T01:14:45Z
Test case:
struct S
{
@property int foo() { return 123; }
void bar() const { foo; }
}
DMD produces the following error message, which is not very useful:
bug.d(4): Error: function a.S.foo () is not callable
using argument types ()
Note that if parentheses are added to the foo() call, the error changes to:
bug.d(4): Error: function bug.S.foo () is not callable
using argument types () const
which is much better.
Comment #1 by bugzilla — 2012-12-10T01:18:12Z
Please disregard the "a.S.foo" in the first error message, which is not part of the problem. It is simply a result of me renaming the source file and only copy-pasting part of the message anew. :)
Comment #2 by andrej.mitrovich — 2012-12-10T08:57:38Z
*** This issue has been marked as a duplicate of issue 6707 ***
Comment #3 by andrej.mitrovich — 2012-12-10T08:58:41Z
Note that in upcoming 2.061 this error is now shown for calls with or without parens, so it's slightly more descriptive:
Error: function test.S.foo () is not callable using argument types () const