Skip to content

Commit

Permalink
update CHANGES.md and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
paulpatault committed Jun 7, 2022
1 parent 6110197 commit 98f6c11
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 19 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

## Improved

- Pattern-matching redundancy is now a warning instead of an error.
[\#222](https://github.com/ocaml-gospel/gospel/pull/222)
- Allow unit result in function header
[\#215](https://github.com/ocaml-gospel/gospel/pull/215)
- Highlight source locations when reporting errors.
Expand Down
2 changes: 1 addition & 1 deletion src/patmat.ml
Original file line number Diff line number Diff line change
Expand Up @@ -568,4 +568,4 @@ let checks ~loc ty cases =
let tyl = ty :: bools in
check_exhaustive ~loc tyl pmat q bools;
check_redundancy ~loc tyl pmat
with W.Warning e -> Fmt.epr "%a@." W.pp_warn e
with W.Warning e -> Fmt.pr "%a@." W.pp_warn e
11 changes: 6 additions & 5 deletions test/patterns/negative/redundant1.mli
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ val f : int -> int
| _ -> true
| 1i -> false *)
(* {gospel_expected|
[125] File "redundant1.mli", line 3, characters 12-58:
3 | ............match x with
4 | | _ -> true
5 | | 1i -> false...
Error: The pattern-matching is redundant.
[0] File "redundant1.mli", line 3, characters 12-58:
3 | ............match x with
4 | | _ -> true
5 | | 1i -> false...
Warning: The pattern-matching is redundant.
Here is a case that is unused:
1i.
OK
|gospel_expected} *)
15 changes: 8 additions & 7 deletions test/patterns/negative/redundant2.mli
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ val f : t -> int
| B (B A) -> false
| _ -> true *)
(* {gospel_expected|
[125] File "redundant2.mli", line 5, characters 12-103:
5 | ............match x with
6 | | A -> false
7 | | B (B _) -> false
8 | | B (B A) -> false
9 | | _ -> true...
Error: The pattern-matching is redundant.
[0] File "redundant2.mli", line 5, characters 12-103:
5 | ............match x with
6 | | A -> false
7 | | B (B _) -> false
8 | | B (B A) -> false
9 | | _ -> true...
Warning: The pattern-matching is redundant.
Here is a case that is unused:
B B A.
OK
|gospel_expected} *)
13 changes: 7 additions & 6 deletions test/patterns/negative/redundant3.mli
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ val f : t -> int
| B (B A) -> false
| _ -> true *)
(* {gospel_expected|
[125] File "redundant3.mli", line 5, characters 12-86:
5 | ............match x with
6 | | A | B _ -> false
7 | | B (B A) -> false
8 | | _ -> true...
Error: The pattern-matching is redundant.
[0] File "redundant3.mli", line 5, characters 12-86:
5 | ............match x with
6 | | A | B _ -> false
7 | | B (B A) -> false
8 | | _ -> true...
Warning: The pattern-matching is redundant.
Here is a case that is unused:
B B A.
OK
|gospel_expected} *)

0 comments on commit 98f6c11

Please sign in to comment.