import std.stdio; class Base { int f() {return 0;} } class Derived : Base { private override /+int+/ f() {return 1;} // accepts-invalid } void main() { }
I agree this looks a bit strange, and it may even lead to a few bugs, but here DMD is acting as designed, so it's not a true bug. When you use enum, override and few other things, DMD performs type inference, so the explicit return type is not necessary. So I presume this bug may be closed. (If you think this D characteristic is leads to many bugs then this bug report may be kept open, despite the probability of seeing it fixed is low.)
Thank you for your reply. If this characteristic is a design of DMD, I will close this bug report. What do you think that both look like asymmetry? import std.stdio; class Base { int f() {return 0;} int g() {return 0;} } class Derived : Base { private override /+int+/ f() {return 1;} // accepts public override /+int+/ g() {return 1;} // rejects } void main() {} main.d(10): Error: function main.Derived.g of type () overrides but is not covariant with main.Base.g of type int() main.d(10): Error: function main.Derived.g does not override any function
I don't know what's going on, but I suggest to keep this bug report open.
I think this is a duplicate of bug 3581.
*** This issue has been marked as a duplicate of issue 3581 ***