[Issue 16221] New: Better compiler error message for @disabled function
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Thu Jun 30 03:22:04 PDT 2016
https://issues.dlang.org/show_bug.cgi?id=16221
Issue ID: 16221
Summary: Better compiler error message for @disabled function
Product: D
Version: D2
Hardware: x86_64
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: acehreli at yahoo.com
(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
--
More information about the Digitalmars-d-bugs
mailing list