auto ref deduction and common type deduction inconsistency
via Digitalmars-d
digitalmars-d at puremagic.com
Wed Aug 20 11:24:29 PDT 2014
On Wednesday, 20 August 2014 at 16:45:49 UTC, ketmar via
Digitalmars-d wrote:
> On Wed, 20 Aug 2014 16:34:40 +0000
> via Digitalmars-d <digitalmars-d at puremagic.com> wrote:
>
>> No, the type of (cond ? x : 42) is always `int`, the `ref`
>> already gets lost inside the ternary operator. So in this
>> case, it behaves correctly.
> it's slightly counterintuitive. yes, this is correct, but D
> already
> complains on things like (a&b == c), so it can complain on such
> returns
> too -- just to avoid disambiguation. something like "use return
> cast(int)".
What would `cast(int)` do in this case? Note that `ref` is not
part of the type -- it's a storage class associated only with the
variable (= parameter).
More information about the Digitalmars-d
mailing list