Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix Issue 16570 - Enum member with interpreted... #6175

Merged
merged 1 commit into from
Oct 8, 2016

Conversation

MartinNowak
Copy link
Member

...initializer has type of initializer not enum

  • There is a very old (dmd 0.50 ¹) mismatch of the CastExp's to type
    and the type painted on the CastExp (the latter being the basetype of
    the former, i.e. EnumType vs. int) in the result of
    Expression.castTo(ed.type).
    Because of that difference interpreting castTo might unexpectedly use
    the basetype instead of the enum type for the enum initializer, and
    thus triggers the can't convert int to EnumType error.
  • The trigger was introduced with the addition of a e.ctfeInterpret in
    denum.d (see 932be19).
  • Comments on CastExp suggest that this type mismatch is actually
    intended, I don't see any reason for it though.
  • Alternatively we could somehow fix ctfeInterpret to preserve CastExp's
    painted type.

...initializer has type of initializer not enum

- There is a very old (dmd 0.50 [¹]) mismatch of the CastExp's `to` type
  and the type painted on the CastExp (the latter being the basetype of
  the former, i.e. EnumType vs. int) in the result of
  `Expression.castTo(ed.type)`.
  Because of that difference interpreting castTo might unexpectedly use
  the basetype instead of the enum type for the enum initializer, and
  thus triggers the can't convert int to EnumType error.

- The trigger was introduced with the addition of a `e.ctfeInterpret` in
  denum.d (see 932be19).

- Comments on CastExp suggest that this type mismatch is actually
  intended, I don't see any reason for it though.

- Alternatively we could somehow fix ctfeInterpret to preserve CastExp's
  painted type.

[¹]: https://github.com/dlang/dmd/blob/bde09435d149c699490bb888b832228e0d31c221/src/cast.c#L321-L323respect
@dlang-bot
Copy link
Contributor

Fix Bugzilla Description
16570 [REG 2.072.0-b1] Enum member with interpreted initializer has type of initializer not enum

@MartinNowak MartinNowak added the Severity:Regression PRs that fix regressions label Oct 6, 2016
@WalterBright
Copy link
Member

Looks good to me, absent the CyberShadow/travis-ci failures.

@MartinNowak
Copy link
Member Author

All unrelated, need to fix them, 3 failures by now.

@MartinNowak
Copy link
Member Author

Auto-merge toggled on

@MartinNowak MartinNowak merged commit fa464f3 into dlang:stable Oct 8, 2016
@MartinNowak MartinNowak deleted the fix16570 branch August 30, 2022 06:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Severity:Regression PRs that fix regressions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants