[Proposal] not specifying all cases in a switch statement generates a compilation error (like in Kotlin) #9316
Unanswered
MihailsKuzmins
asked this question in
Language Ideas
Replies: 1 comment 2 replies
-
You can make that warning be treated as an error in your project file. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
First of all, I apologise if a similar discussion has already been opened (something like #782).
The current behaviour must not be changed, so maybe it is possible to introduce a new keyword (like
required
) to force a compilation error if not all cases are specified.The code snippet below generates a warning, but compiles:
The 'switch' expression does not handle all possible inputs (it is not exhaustive). For example, the pattern 'Test.Test3' is not covered.
It would be nice to have something that gives errors (obvious feedback) when a new enum is added.
Beta Was this translation helpful? Give feedback.
All reactions