Bug 6373 – More descriptive 'hidden by X is deprecated' error

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-07-24T06:04:00Z
Last change time
2015-06-09T05:11:38Z
Keywords
diagnostic, patch, pull
Assigned to
nobody
Creator
bearophile_hugs

Attachments

IDFilenameSummaryContent-TypeSize
1013difference.txtdiff to toobj.ctext/plain1732

Comments

Comment #0 by bearophile_hugs — 2011-07-24T06:04:20Z
Wrong D2 code: class Foo { void method(int x) {} void method(double x) {} } class Bar : public Foo { // line 5 override void method(int x) {} } void main() { Foo f = new Bar(); f.method(1); f.method(1.5); } DMD 2.054 gives the error: test.d(5): Error: class test.Bar use of test.Foo.method(double x) hidden by Bar is deprecated While this program gives no errors: class Foo { void method(int x) {} void method(double x) {} } class Bar : public Foo { alias Foo.method method; override void method(int x) {} } void main() { Foo f = new Bar(); f.method(1); f.method(1.5); } In the error message I suggest to add some reference to this usage of alias, because in D.learn I've seen some D programmers blocked by this error message. A possible message (also note the error line number, 6 instead of 5): test.d(6): Error: class test.Bar use of test.Foo.method(double x) hidden by Bar is deprecated. Use alias Foo.method method; if intended. Or even, to be more clear: test.d(6): Error: class test.Bar use of test.Foo.method(double x) hidden (not overridden) by Bar is deprecated. Use alias Foo.method method; if intended.
Comment #1 by bearophile_hugs — 2011-07-26T08:24:32Z
Comment #2 by bearophile_hugs — 2011-07-26T08:27:28Z
Raised importance from minor to normal because already 4 persons have asked for help on this.
Comment #3 by bearophile_hugs — 2011-07-27T18:50:27Z
Created attachment 1013 diff to toobj.c A kind of patch over dmd 2.054, probably wrong. Be kind.
Comment #4 by code — 2011-07-28T10:40:11Z
Besides the fact that pull requests are preferred for cases where you are reasonably sure that you patch is worth closer inspection/inclusion, please use the unified diff format (diff -u) for patches. It it the de-facto standard in the open source world and makes it easier to review changes.
Comment #5 by andrej.mitrovich — 2012-11-29T07:59:19Z
Comment #6 by github-bugzilla — 2012-12-09T09:52:55Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/dc8ccc35c015c19e6b80dc7ec6950b3038d9c79c Fixes Issue 6373 - Add more descriptive error message when base class method is hidden. https://github.com/D-Programming-Language/dmd/commit/ce7f3d86e7faf468eb6b64410d00084e9dce6e28 Merge pull request #1335 from AndrejMitrovic/Fix6373 [diag] Issue 6373 - Add more descriptive error message when base class method is hidden
Comment #7 by bearophile_hugs — 2012-12-09T10:42:21Z
On GigHub in your little patch the new line 814 seems very very long.
Comment #8 by andrej.mitrovich — 2012-12-20T15:00:53Z
*** Issue 4216 has been marked as a duplicate of this issue. ***