diff options
| author | Thomas Bauereiss | 2019-06-12 17:15:10 +0100 |
|---|---|---|
| committer | Thomas Bauereiss | 2019-06-12 17:48:19 +0100 |
| commit | d61140c5a922d8781356aa874a2fe2a7a36ed0ee (patch) | |
| tree | d8caae8ac3e9ab0edcc291c96af293e836f6a264 /src/pattern_completeness.ml | |
| parent | 22123333fc80bf5d3ee73c6692f3fba44892bcee (diff) | |
Handle partial matches in guarded pattern rewrite
Add a fallthrough case that fails to potentially partial pattern
matches. This also helps to preserve any guard in the final match case,
which might be needed for flow typing (see the discussion on issue #51).
TODO: Merge with the MakeExhaustive rewrite, which currently does not
support guarded patterns.
Diffstat (limited to 'src/pattern_completeness.ml')
| -rw-r--r-- | src/pattern_completeness.ml | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/pattern_completeness.ml b/src/pattern_completeness.ml index 3e26502d..3de0058f 100644 --- a/src/pattern_completeness.ml +++ b/src/pattern_completeness.ml @@ -286,6 +286,13 @@ let shrink_loc = function Lexing.(Parse_ast.Range (n, { n with pos_cnum = n.pos_cnum + 5 })) | l -> l +let is_complete ctx cases = + match cases_to_pats cases with + | [] -> false + | (_, pat) :: pats -> + let top_pat = List.fold_left (combine ctx) (generalize ctx pat) pats in + is_wild top_pat + let check l ctx cases = match cases_to_pats cases with | [] -> Reporting.warn "No non-guarded patterns at" (shrink_loc l) "" |
