You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 6438 Reporter:@mjambon Assigned to:@maranget Status: closed (set by @maranget on 2014-06-03T12:45:17Z) Resolution: won't fix Priority: low Severity: minor Version: 4.01.0 Category: ~DO NOT USE (was: OCaml general) Has duplicate:#7059 Monitored by:@gasche
Bug description
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
OCaml version 4.01.0
function Some x -> x;;
Warning 8: this pattern-matching is not exhaustive.
Here is an example of a value that is not matched:
None
Error: Some fatal warnings were triggered (1 occurrences)
function Some x when x = 0 -> x;;
Warning 25: bad style, all clauses in this pattern-matching are guarded.
: int option -> int =
The text was updated successfully, but these errors were encountered:
This seems to be more a problem of design of the warnings.
Warning 25 implies warning 8, but some people do not even know its existence.
One could also generate a warning 8, but this does not add extra information.
I'm kind of wondering why the two warnings are distinct.
Consider however that warning 25 (all clauses are guarded)
is enabled by default and that programming that way is bad style...
For the record exhaustiveness check
is performed after having deleted all guarded clauses.
Hence, in the all-guarded clause case, warning 8 should always be activated
(a pattern matching with no clause always fails and thus should be considered
as non-exhaustive).
However, should such a all-guarded PM occur, programmer's reaction
should probably go beyond simply add some clauses. Hence the specific warning.
This is really very bad style.
Original bug ID: 6438
Reporter: @mjambon
Assigned to: @maranget
Status: closed (set by @maranget on 2014-06-03T12:45:17Z)
Resolution: won't fix
Priority: low
Severity: minor
Version: 4.01.0
Category: ~DO NOT USE (was: OCaml general)
Has duplicate: #7059
Monitored by: @gasche
Bug description
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
OCaml version 4.01.0
function Some x -> x;;
Warning 8: this pattern-matching is not exhaustive.
Here is an example of a value that is not matched:
None
Error: Some fatal warnings were triggered (1 occurrences)
function Some x when x = 0 -> x;;
Warning 25: bad style, all clauses in this pattern-matching are guarded.
The text was updated successfully, but these errors were encountered: