auto ref deduction and common type deduction inconsistency
via Digitalmars-d
digitalmars-d at puremagic.com
Wed Aug 20 08:24:17 PDT 2014
On Wednesday, 20 August 2014 at 15:08:52 UTC, Peter Alexander
wrote:
> On Wednesday, 20 August 2014 at 14:52:59 UTC, ketmar via
> Digitalmars-d wrote:
>> On Wed, 20 Aug 2014 14:44:40 +0000
>> Peter Alexander via Digitalmars-d
>> <digitalmars-d at puremagic.com> wrote:
>>
>>> Well, the return type is already the common type of all
>>> return paths
>> no, it's not. the return type will be taken from the first
>> return
>> statement in code.
>
> auto foo() {
> if (1) return 1;
> return 2.0;
> }
>
> This returns double. Try for yourself.
Then either the compiler or the documentation is wrong :-(
"If there are multiple ReturnStatements, the types of them must
match exactly."
http://dlang.org/function#auto-functions
More information about the Digitalmars-d
mailing list