D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 23188 - The enum of const has a complier exception of type conversion in the ternary operator.
Summary: The enum of const has a complier exception of type conversion in the ternary ...
Status: RESOLVED DUPLICATE of issue 23172
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Mac OS X
: P1 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-06-15 01:57 UTC by shove
Modified: 2022-06-15 09:29 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description shove 2022-06-15 01:57:50 UTC
enum Status : byte
{
    A, B, C
}

void main()
{

}

Status foo()
{
    Status t = Status.A;
    const Status s = t;

    return (s == Status.A) ? Status.B : s;  // <-- here
}

# dmd app.d
app.d(16): Error: cannot implicitly convert expression `cast(int)s == 0 ? 1 : cast(int)s` of type `int` to `Status`

/////////////////////////////////////////

So there's no problem:

Status foo()
{
    Status t = Status.A;
    const Status s = t;

    if (s == Status.A)
        return Status.B;
    return s;
}
Comment 1 shove 2022-06-15 02:54:06 UTC
https://issues.dlang.org/show_bug.cgi?id=23172

It should be the same problem.
Comment 2 basile-z 2022-06-15 09:29:04 UTC
yes it is, there's an inapropriate integral promotion since 2.100.0

*** This issue has been marked as a duplicate of issue 23172 ***