D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4855 - When a class has private override member function, the function requires no return value type
Summary: When a class has private override member function, the function requires no r...
Status: RESOLVED DUPLICATE of issue 3581
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Windows
: P2 normal
Assignee: No Owner
URL:
Keywords: accepts-invalid, rejects-valid, spec
Depends on:
Blocks:
 
Reported: 2010-09-12 07:09 UTC by Haruki Shigemori
Modified: 2012-01-29 21:53 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Haruki Shigemori 2010-09-12 07:09:36 UTC
import std.stdio;
class Base
{
        int f() {return 0;}
}
class Derived : Base
{
        private override /+int+/ f() {return 1;} // accepts-invalid
}
 
void main()
{
}
Comment 1 bearophile_hugs 2010-09-12 07:59:36 UTC
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.)
Comment 2 Haruki Shigemori 2010-09-12 09:55:48 UTC
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
Comment 3 bearophile_hugs 2010-09-12 11:14:20 UTC
I don't know what's going on, but I suggest to keep this bug report open.
Comment 4 Don 2010-09-12 19:05:39 UTC
I think this is a duplicate of bug 3581.
Comment 5 yebblies 2012-01-29 21:53:57 UTC

*** This issue has been marked as a duplicate of issue 3581 ***