import std.stdio;
enum abc:int{
vv,cc
}
enum kkk:abc
{
mm = cast(abc)(abc.cc+1)
}
void main()
{
kkk t;
t = kkk.vv; // this should work? instead I get this error message: Error: cannot implicitly convert expression (cast(abc)0) of type abc to kkk
}
Comment #1 by fvbommel — 2009-04-20T01:33:00Z
*** Bug 2860 has been marked as a duplicate of this bug. ***
Comment #2 by hsteoh — 2015-08-24T04:51:46Z
Still happens on git HEAD. Verified on git HEAD (5b468ace36ac8eaa6de215b1e376aece9ccc1084), Linux/64-bit.
Comment #3 by razvan.nitu1305 — 2019-09-17T10:17:59Z
Shouldn't this be an error that kkk does not devine member vv? I can't find anything about this in the spec.
Comment #4 by nick — 2023-08-08T17:00:30Z
> Shouldn't this be an error that kkk does not devine member vv?
It still errors if you replace the last line with:
t = abc.vv;
(I think because kkk.vv doesn't exist, the compiler looks in the base type to see if it defines vv.)
Comment #5 by nick — 2023-08-08T17:05:42Z
I think the error is correct according to the spec:
> EnumBaseType types cannot be implicitly cast to an enum type.
https://dlang.org/spec/enum.html#named_enums
abc.vv (or kkk.vv which resolves to that) is of type abc, so it can't be cast to type kkk, which t is.
Comment #6 by robert.schadek — 2024-12-13T17:49:50Z