Bug 17602 – improve message for deprecated enum comparison
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-07-05T13:16:48Z
Last change time
2018-06-19T18:40:14Z
Keywords
diagnostic
Assigned to
No Owner
Creator
Mario Kroeplin
Comments
Comment #0 by kroeplin.d — 2017-07-05T13:16:48Z
Currently, the message is misleading:
Deprecation: Comparison between different enumeration types const(Status) and Status; If this behavior is intended consider using std.conv.asOriginalType
The actual problem in this case is that different enumerations with the same name "Status" are defined in different modules.
Comment #1 by razvan.nitu1305 — 2018-06-14T14:30:42Z
Can you please offer a test case?
Comment #2 by kroeplin.d — 2018-06-15T11:46:49Z
It is no longer a deprecation warning but an error message.
The error message, however, is still misleading:
---
module a;
enum Status { on }
---
module b;
import a;
enum Status { off }
void main()
{
Status status = a.Status.on;
}
---
> dmd a.d b.d
Error: cannot implicitly convert expression cast(Status)0 of type Status to Status
Comment #3 by razvan.nitu1305 — 2018-06-19T09:36:07Z