Enforcing exhaustive coverage in case statement is an awesome feature, but sometimes you don't know if you have covered all cases or not. This creates the following situation where there is always a possibility to get an error:
else: discard statement -> not all cases are covered
else: discard statement ----> invalid else, all cases are already coveredThis of course is no problem during the general development case, because the compiler will just inform you whether you are covering all cases or not, which is great. In case you are generating code though, getting such compile errors when you know your generated code is correct can be bothersome.
Introduce a pragma for disabling the check of exhaustive coverage. Possible names:
{.dirtyCase.}{.lenientCase.}Change Error: invalid else, all cases are already covered into a warning.
Why not just generate the else: clause in your bothersome cases?
I have no specific bothersome cases. The codegen must be generic because I have no way to distinguish between when I should and when I should not generate it.
I think this
discard statement ----> invalid else, all cases are already covered
should be made a warning instead of an error.
Then no new language features are required.
Oh, @Clyybber actually your solution sounds great!
I'm in favor of this after talking to Clyybber. It's more ergonomic for the programmer.
Most helpful comment
I think this
should be made a warning instead of an error.
Then no new language features are required.