Bug 21828 – Enum forward-references just assume int base type
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-04-15T10:41:46Z
Last change time
2021-04-16T07:27:33Z
Keywords
pull, rejects-valid
Assigned to
No Owner
Creator
Vladimir Panteleev
Comments
Comment #0 by dlang-bugzilla — 2021-04-15T10:41:46Z
//////// test.d ////////
struct S
{
enum E
{
e1 = 0,
}
E e;
enum S s1 = S(E.e1);
}
SE se;
enum SE
{
e1 = S.s1
}
////////////////////////
test.d(8,15): Error: cannot implicitly convert expression `S(E.e1)` of type `S` to `int`
If the declaration of `SE` and the use `SE se;` are reordered, the problem goes away.
Comment #1 by dlang-bot — 2021-04-15T15:41:40Z
@RazvanN7 created dlang/dmd pull request #12437 "Fix Issue 21828 - Using enum of struct (containing another enum) before its declaration fails" fixing this issue:
- Fix Issue 21828 - Using enum of struct (containing another enum) before its declaration fails
https://github.com/dlang/dmd/pull/12437
Comment #2 by dlang-bot — 2021-04-15T15:54:51Z
@BorisCarvajal created dlang/dmd pull request #12438 "Fix Issue 21828 - Using enum of struct (containing another enum) befo…" fixing this issue:
- Fix Issue 21828 - Using enum of struct (containing another enum) before its declaration fails
https://github.com/dlang/dmd/pull/12438
Comment #3 by boris2.9 — 2021-04-15T18:44:20Z
reduced test case:
----
E e;
enum E
{
a = "x"
}
----
Forward references just assume int value.
Comment #4 by dlang-bot — 2021-04-16T07:27:33Z
dlang/dmd pull request #12438 "Fix Issue 21828 - Enum forward-references just assume int base type" was merged into master:
- 38a016e434505cb642aab480142a40343e2b4174 by Boris Carvajal:
Fix Issue 21828 - Enum forward-references just assume int base type
https://github.com/dlang/dmd/pull/12438