From ae5f911f76dedd93903e2a3b4322bba444a2dae0 Mon Sep 17 00:00:00 2001 From: xvw Date: Fri, 23 Feb 2024 12:06:42 +0100 Subject: [PATCH 1/2] destruct: Removal of residual patterns --- src/analysis/destruct.ml | 5 +- tests/test-dirs/destruct/issue1560.t | 162 +++++++++++++++++++++++++++ 2 files changed, 163 insertions(+), 4 deletions(-) create mode 100644 tests/test-dirs/destruct/issue1560.t diff --git a/src/analysis/destruct.ml b/src/analysis/destruct.ml index e30f456384..e1941ceae2 100644 --- a/src/analysis/destruct.ml +++ b/src/analysis/destruct.ml @@ -584,10 +584,7 @@ let rec node config source selected_node parents = subst_patt patt ~by top_patt ) in - let patterns = - List.rev_append rev_before - (List.append new_branches after) - in + let patterns = after @ rev_before @ new_branches in let unused = Parmatch.return_unused patterns in let new_branches = List.fold_left unused ~init:new_branches ~f:(fun branches u -> diff --git a/tests/test-dirs/destruct/issue1560.t b/tests/test-dirs/destruct/issue1560.t new file mode 100644 index 0000000000..e328d8012b --- /dev/null +++ b/tests/test-dirs/destruct/issue1560.t @@ -0,0 +1,162 @@ + $ $MERLIN single case-analysis -start 2:29 -end 2:29 \ + > -filename main.ml < type t = A of int | B | C + > let f = function A x -> x | _ -> 1 + > EOF + { + "class": "return", + "value": [ + { + "start": { + "line": 2, + "col": 28 + }, + "end": { + "line": 2, + "col": 29 + } + }, + "B | C" + ], + "notifications": [] + } + + $ $MERLIN single case-analysis -start 2:18 -end 2:18 \ + > -filename main.ml < type t = A of int | B | C + > let f = function A x -> x + > EOF + { + "class": "return", + "value": [ + { + "start": { + "line": 2, + "col": 25 + }, + "end": { + "line": 2, + "col": 25 + } + }, + " + | B | C -> _" + ], + "notifications": [] + } + + + $ $MERLIN single case-analysis -start 2:29 -end 2:29 \ + > -filename main.ml < type t = A of int | B | C + > let f = function A 0 -> 0 | _ -> 1 + > EOF + { + "class": "return", + "value": [ + { + "start": { + "line": 2, + "col": 28 + }, + "end": { + "line": 2, + "col": 29 + } + }, + "A _ | B | C" + ], + "notifications": [] + } + + $ $MERLIN single case-analysis -start 2:29 -end 2:29 \ + > -filename main.ml < type t = A of int | B | C + > let f = function A x -> x | _ -> 1 | C -> 2 + > EOF + { + "class": "return", + "value": [ + { + "start": { + "line": 2, + "col": 28 + }, + "end": { + "line": 2, + "col": 29 + } + }, + "B" + ], + "notifications": [] + } + + $ $MERLIN single case-analysis -start 2:38 -end 2:38 \ + > -filename main.ml < type t = A of int | B | C + > let f = function A x -> x | C -> 2 | _ -> 1 + > EOF + { + "class": "return", + "value": [ + { + "start": { + "line": 2, + "col": 37 + }, + "end": { + "line": 2, + "col": 38 + } + }, + "B" + ], + "notifications": [] + } + + $ $MERLIN single case-analysis -start 2:47 -end 2:47 \ + > -filename main.ml < type t = A of int | B | C | D + > let f = function A x -> x | B -> 2 | D -> 1 | _ -> 3 + > EOF + { + "class": "return", + "value": [ + { + "start": { + "line": 2, + "col": 46 + }, + "end": { + "line": 2, + "col": 47 + } + }, + "C" + ], + "notifications": [] + } + + $ $MERLIN single case-analysis -start 2:47 -end 2:47 \ + > -filename main.ml < type t = A of int | B | C | D + > let f = function A 2 -> 2 | B -> 2 | D -> 1 | _ -> 3 + > EOF + { + "class": "return", + "value": [ + { + "start": { + "line": 2, + "col": 46 + }, + "end": { + "line": 2, + "col": 47 + } + }, + "A _ | C" + ], + "notifications": [] + } From af62e1262e23b951cc1a62e72738ec617b89ecfb Mon Sep 17 00:00:00 2001 From: xvw Date: Fri, 23 Feb 2024 12:22:51 +0100 Subject: [PATCH 2/2] Add CHANGES entry --- CHANGES.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index bb4de3cb2a..bcb9912894 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,9 @@ +merlin NEXT_VERSION +================== + + + merlin binary + - destruct: Removal of residual patterns (#1737, fixes #1560) + merlin 4.14 =========== Thu Feb 22 14:00:42 CET 2024