July 23 [Issue 24671] New: Improve error message on override mismatch | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24671 Issue ID: 24671 Summary: Improve error message on override mismatch Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: dmd Assignee: nobody@puremagic.com Reporter: qs.il.paperinik@gmail.com When trying to override an inherited method, there are three kinds of error: - No base class method with the given name exists. - There are base class methods with that name, but all are final. - There is at least one overridable base class method with that name, but the signature is incompatible. In the first case, try typo correction. In the second case, tell the user there are no non-final methods available. Also try typo correction. In the third case, when signatures are incompatible, print both the signatures and point out the difference in a diff style manner. That is, in the derived class’s method that tries to override, use red for stuff to be removed and green for stuff that would have to be added. If there is an overload in the base class that has exactly as many parameters as the would-be overload, only do the diff for the overloads with the right number of parameters; otherwise do the diff for all base class overloads with the right name. Example case: ``` Error: function `pure nothrow @nogc @safe int app.D.f(int delegate(int) pure nothrow @nogc @safe body)` does not override any function, did you mean to override `pure nothrow @nogc @safe int app.B.f(scope int delegate(int) pure nothrow @nogc @safe)`? ``` Better: ``` Error: function `pure nothrow @nogc @safe int app.D.f(int delegate(int) pure nothrow @nogc @safe body)` does not override any function, did you mean to override `pure nothrow @nogc @safe int app.B.f(scope int delegate(int) pure nothrow @nogc @safe)`? Did you intend to override like this: pure nothrow @nogc @safe int f(scope int delegate(int) pure nothrow @nogc @safe) ^^^^^ (addition) ``` -- |
Copyright © 1999-2021 by the D Language Foundation