D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 21544 - -checkaction=context formats enum members as their base type
Summary: -checkaction=context formats enum members as their base type
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: druntime (show other issues)
Version: D2
Hardware: All All
: P1 minor
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2021-01-13 00:33 UTC by moonlightsentinel
Modified: 2021-01-25 13:33 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description moonlightsentinel 2021-01-13 00:33:59 UTC
-checkaction=context doesn't recognize enums, e.g.:

enum E { A, BCDE }

void main() 
{
    E a = E.A;
    E b = E.BCDE;
    assert(a == b);
}

core.exception.AssertError@onlineapp.d(7): 0 != 1

The error message should probably print the exact member or at least include `cast(E)` as done e.g. for static assert.
Comment 1 Dlang Bot 2021-01-21 12:07:26 UTC
@MoonlightSentinel created dlang/druntime pull request #3336 "Fix 21544 - -checkaction=context formats enum members as their base type" fixing this issue:

- Fix 21544 - -checkaction=context formats enum members as their base type
  
  Generate code that detects the correct enum member (or defaults to the
  base type in case of an invalid enum value).

https://github.com/dlang/druntime/pull/3336
Comment 2 Dlang Bot 2021-01-25 13:33:31 UTC
dlang/druntime pull request #3336 "Fix 21544 - -checkaction=context formats enum members as their base type" was merged into master:

- 02dd9d99f415ba1ba4fae6e2d590a967cd03c385 by MoonlightSentinel:
  Fix 21544 - -checkaction=context formats enum members as their base type
  
  Generate code that detects the correct enum member (or defaults to the
  base type in case of an invalid enum value).

https://github.com/dlang/druntime/pull/3336