Discussion Thread: DIP 1043--Shortened Method Syntax--Community Review Round 1

Timon Gehr timon.gehr at gmx.ch
Fri Feb 4 18:21:44 UTC 2022


On 04.02.22 19:03, Basile B. wrote:
> On Friday, 4 February 2022 at 17:18:54 UTC, Tejas wrote:
>> So maybe the fact that `this(string y) => this(0, y);` doesn't compile 
>> is a compiler bug? Constructors return `void` after all, no?
> 
> No, aggregate ctors are not `void` but the return is generated [by the 
> compiler](https://github.com/dlang/dmd/blob/51882e40fd17ed4b57a8ce3a355ea76b55d777c9/src/dmd/semantic3.d#L771-L780). 
> 
> 

That's an implementation/ABI detail. Plain "return" is allowed, just as 
if the constructor returned `void`.

https://github.com/dlang/dmd/blob/51882e40fd17ed4b57a8ce3a355ea76b55d777c9/src/dmd/statementsem.d#L2849-L2852

Therefore, it makes sense to do this rewrite in constructors too:
https://github.com/dlang/dmd/blob/51882e40fd17ed4b57a8ce3a355ea76b55d777c9/src/dmd/statementsem.d#L2896-L2910


More information about the Digitalmars-d mailing list