Add a -vet-empty-case to help with switch bugs #5561
virror
started this conversation in
Ideas/Requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
The problem:
A lot of people including my self seem to port projects and/or are used to other languages where case fallthrough is the default behavior for switch statements. This translates badly to Odin and easily causes bugs in the code when things like:
case: a
case: b
should instead look like:
case a, b:
The solution:
One solution would be to add a -vet-empty-case to throw errors when having empty cases and instead promote using a break when an empty case is intended. This would both help a lot against bugs but also increase the readability of the code by more clearly showing the intent.
This has been discussed briefly in the Discussion discord and got positive feedback.
Beta Was this translation helpful? Give feedback.
All reactions