Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

destruct: Removal of residual patterns fix #1560 #1737

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 1 addition & 4 deletions src/analysis/destruct.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand Down
162 changes: 162 additions & 0 deletions tests/test-dirs/destruct/issue1560.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
$ $MERLIN single case-analysis -start 2:29 -end 2:29 \
> -filename main.ml <<EOF
> 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 <<EOF
> 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 <<EOF
> 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 <<EOF
> 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 <<EOF
> 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 <<EOF
> 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 <<EOF
> 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": []
}
Loading