Name of enum variant with fields is suggested in error messages #73427
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
D-confusing
Diagnostics: Confusing error or lint that should be reworked.
D-newcomer-roadblock
Diagnostics: Confusing error or lint; hard to understand for new users.
D-papercut
Diagnostics: An error or lint that needs small tweaks.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
The following code:
gives the following error message
MyEnum::First.foo()
callsfoo
on a function pointer (the constuctor function forMyEnum::First
, which is almost never what you want.At the very least, we should not be suggesting using enum variants that have associated data. When attempting to call a method on the base enum type, we might want to suggest using
::
instead (e.g.MyEnum::First::foo()
), which is more likely to be what the user wants.The text was updated successfully, but these errors were encountered: