Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Pattern guard disables exhaustiveness check #6438
Original bug ID: 6438
The example below is what happened in actual code. If there's a 'when' guard in a pattern match, exhaustiveness checking seems to be completely turned off, even if ignoring the guards could detect cases that are not covered.
A useful behavior would be, when some or all patterns are guarded, to check for exhaustiveness while ignoring all guards.
But using '-warn-error +8+25' instead of just '-warn-error +8' would work fine too. So maybe it's not worth bothering with this.
$ ocaml -warn-error +8
function Some x -> x;;
Warning 8: this pattern-matching is not exhaustive.
function Some x when x = 0 -> x;;
Warning 25: bad style, all clauses in this pattern-matching are guarded.
Comment author: @garrigue
This seems to be more a problem of design of the warnings.
Comment author: @maranget
I do not really remember either :)
Consider however that warning 25 (all clauses are guarded)
For the record exhaustiveness check
If nobody objects, I'll close the issue.