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

handle "default" case #1

Closed
dcu opened this issue May 23, 2020 · 1 comment
Closed

handle "default" case #1

dcu opened this issue May 23, 2020 · 1 comment

Comments

@dcu
Copy link

dcu commented May 23, 2020

currently the "default:" case is not handled well and the this checker asks to cover all cases even when default does that

@nishanths
Copy link
Owner

nishanths commented May 23, 2020

Thanks for the report. Setting the -default-signifies-exhaustive flag should provide the behavior you're looking for. Setting this flag will make the checker consider switch statements exhaustive as long as a default case is present, even if all enum members aren't explicitly listed in the switch.

The reported behavior was by design for a couple of reasons. If the existence of a default case made the switch exhaustive, it would invalidate the purpose of checking for exhaustiveness.

Secondly, otherwise it would not be possible for the program to point out switch statements that may need to be updated when new enum members are added. (The existence of a default case does not necessarily mean that an existing switch doesn't need to be updated to account for the new enum members.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants