digitalmars.D - Constructor-calls
- Mafi (36/36) Feb 25 2011 Hi all,
- Peter Alexander (2/5) Feb 25 2011 Submit an enhancement request.
Hi all, dmd gets on my nerves with constructor-calls. First I tried the following which dmd complains about. enum SomeEnum { A, B} class D : C { this(int); this(string); this(SomeEnum s) { final switch(s) { case SomeEnum.A: this("Hello"); break; case SomeEnum.B: this(3); break; } } } dmd says it's not valid because constructor-calls are not valid behind labels. But these labels are the cases of a final switch with no gotos in it. IMO my code is perfectly valid and dmd should see it. It shouldn't be too complicated check because final switch already enforces breaks and that all possible paths a defined. Just check if it's final switch and there are no 'goto case's in there. class D : C { this(int); this(string); this(SomeEnum s) { if(s == SomeEnum.A) { this("Hello"); } else if(s == SomeEnum.B) { this(3); } else assert(0); } } It says now that one path does not have constructor-call. This is ridicolous. I mean it's an assert(0) which is statically known to fail. It should check if all paths call constructors or _fail_ IMO. Mafi
Feb 25 2011
On 25/02/11 4:24 PM, Mafi wrote:Hi all, ... MafiSubmit an enhancement request.
Feb 25 2011
Am 25.02.2011 20:01, schrieb Peter Alexander:On 25/02/11 4:24 PM, Mafi wrote:I'll do when I find time!Hi all, ... MafiSubmit an enhancement request.
Feb 26 2011
Mafi wrote:Am 25.02.2011 20:01, schrieb Peter Alexander:I've done it for you. http://d.puremagic.com/issues/show_bug.cgi?id=5669On 25/02/11 4:24 PM, Mafi wrote:I'll do when I find time!Hi all, ... MafiSubmit an enhancement request.
Feb 28 2011