On Tuesday, March 10, 2015 13:26:00 Ali Çehreli via Digitalmars-d-learn wrote: > On 03/10/2015 11:05 AM, Ali Çehreli wrote: > > > In other words, the result of the implicit conversion is an rvalue > > Steven Schveighoffer says there is no rvalue in this case; "an enum is a > derivative": > > https://issues.dlang.org/show_bug.cgi?id=14269#c14
Implicit conversions result in rvalues, not lvalues. What's potentially different about enums is that underneath the hood, there's no difference between an enum and its base type - they're represented exactly the same in terms of bits; it's just the type system that treats them differently. So, the implicit conversion just changes how the type system treats it rather than the object's representation. So, it's possible to make it work so that a ref argument of the base type accepts a variable of the enum type, whereas that doesn't work with something like classes or even different integral types. An implicit conversion of an enum variable to its base type is one of the few cases where you even _could_ have an implicit conversion involving ref, but implicit conversions are supposed to result in rvalues as far as D's type system is concerned, so the fact that you could pass an enum value to a function taking its base type as a ref argument was definitely a bug. - Jonathan M Davis