2.067 Beta: Behavior of enum and ref changed
Meta via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Mar 10 01:19:27 PDT 2015
On Tuesday, 10 March 2015 at 07:04:48 UTC, Andre wrote:
> Hi,
>
> following coding raises a compiler error with the beta of 2.067.
> Is this error intended or not?
> It is working if I change first line of main to: ulong bits;
>
> enum Bits: ulong
> {
> none = 0
> }
>
> bool hasBit(ref ulong rBits, ulong rBit)
> {
> return cast(bool)(rBits & rBit);
> }
>
> void main()
> {
> Bits bits;
> hasBit(bits, Bits.none);
> }
>
> function app.hasBit (ref ulong rBits, ulong rBit) is not
> callable using argument types (Bits, Bits)
>
> Kind regards
> André
It's because enums are not implicitly convertible to their base
type. It was probably a compiler bug that it worked before. It's
a regression however, so I'll file an issue in Bugzilla. In the
meantime you can do:
hasBit(cast(ulong)bits, Bits.none);
Or just use a ulong as you mentioned.
More information about the Digitalmars-d-learn
mailing list