Bug 24671 – Improve error message on override mismatch

Status
NEW
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2024-07-23T10:11:20Z
Last change time
2024-12-13T19:36:33Z
Assigned to
No Owner
Creator
Bolpat
Moved to GitHub: dmd#20489 →

Comments

Comment #0 by qs.il.paperinik — 2024-07-23T10:11:20Z
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) ```
Comment #1 by robert.schadek — 2024-12-13T19:36:33Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20489 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB