Bug 16221 – Better compiler error message for @disabled function
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-06-30T10:22:04Z
Last change time
2018-07-01T19:50:48Z
Keywords
diagnostic
Assigned to
No Owner
Creator
Ali Cehreli
Comments
Comment #0 by acehreli — 2016-06-30T10:22:04Z
(This may be related to bug 11747.)
The following code would fail compilation anyway because const(B)'s A member has a @disabled opEquals:
struct A {
@disable bool opEquals(A);
}
void main() {
auto a = const(A)();
if (a == a) {}
}
However, although technically correct, the error message is about function being non-const:
Error: mutable method deneme.A.opEquals is not callable using a const object
The message is misleading because it sounds as if making it const would work. Let's try it:
@disable bool opEquals(A) const; // <-- now const
Ok, only now the error is clear:
Error: function deneme.A.opEquals is not callable because it is annotated with @disable
I'm creating this bug because it was relatively harder to determine what was wrong in a more complex piece of code where A was a member of another object.
Ali