You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
publicenumMyEnum{public static implicitoperatoruint(Self self)=> self;
public staticimplicitoperatorint(Self);caseA;caseB;caseC;}static{publicstaticvoidMain(){MyEnume=?;inti=e;// Works!uint8u=(uint8)e;// Also works!}}
I discovered this issue while experimenting with #2150. The code above is identical to that issue except for two changes:
The explicit cast uses uint8, not uint.
There's a new public static implicit operator uint(Self self) => self; in MyEnum.
This code compiles successfully. However, swapping the order of the two implicit operators (i.e. int first, then uint) reintroduces the same issue as #2150 ("Unable to implicitly cast int8 to uint8"). This indicates that declaration affects how operators are resolved. Whether this behavior is "correct" may be up for debate, but I'd argue it's unintuitive.
The text was updated successfully, but these errors were encountered:
I discovered this issue while experimenting with #2150. The code above is identical to that issue except for two changes:
uint8
, notuint
.public static implicit operator uint(Self self) => self;
inMyEnum
.This code compiles successfully. However, swapping the order of the two implicit operators (i.e.
int
first, thenuint
) reintroduces the same issue as #2150 ("Unable to implicitly castint8
touint8
"). This indicates that declaration affects how operators are resolved. Whether this behavior is "correct" may be up for debate, but I'd argue it's unintuitive.The text was updated successfully, but these errors were encountered: