Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
24319eb
Add change entry.
Tim-ats-d May 16, 2025
a7a3729
Add a new command to extract expression into a fresh let binding.
Tim-ats-d Jul 16, 2025
500487f
Merge branch 'main' into refactor-extraction
Tim-ats-d Jul 16, 2025
1595bf4
Code quality.
Tim-ats-d Jul 17, 2025
d2d6e08
Add a function to determine if an expression is extractable inside a …
Tim-ats-d Jul 18, 2025
38055ff
More tests.
Tim-ats-d Jul 18, 2025
f388319
Attempt to fix a bug with binding belonging to a module.
Tim-ats-d Jul 18, 2025
1795632
Add change entry.
Tim-ats-d Jul 18, 2025
aee93b0
Add another test.
Tim-ats-d Jul 18, 2025
7f90f47
Fix generation for parameter that appears twice, parenthised generat…
Tim-ats-d Jul 21, 2025
baedfc7
Code quality.
Tim-ats-d Jul 21, 2025
3627558
Replace location heuristic by a proper analysis.
Tim-ats-d Jul 21, 2025
195ed6d
Remove path of value living in a module inside extracted expression.
Tim-ats-d Jul 22, 2025
af58896
Make extraction works in submodule.
Tim-ats-d Jul 24, 2025
b064a8b
Clean up expression before printing.
Tim-ats-d Jul 25, 2025
f3db927
Generate a suffix when a name is given and already used in current sc…
Tim-ats-d Jul 25, 2025
7551d2f
Fix a test.
Tim-ats-d Jul 25, 2025
d1d3c11
Take Ulysse's comments into account.
Tim-ats-d Sep 8, 2025
bc4e53d
Merge branch 'main' into refactor-extraction
Tim-ats-d Sep 8, 2025
c50af5b
Remove function type declaration.
Tim-ats-d Sep 8, 2025
28a421e
Fix constant extraction nested in a modules.
Tim-ats-d Sep 8, 2025
7fe97e7
Last fixes.
Tim-ats-d Sep 9, 2025
32f03f0
WIP.
Tim-ats-d Sep 9, 2025
daf74d9
Reproduce a bug.
Tim-ats-d Sep 9, 2025
7a00505
Merge branch 'state-of-work' into refactor-extraction
Tim-ats-d Sep 9, 2025
3ec6dcc
Last fixes.
Tim-ats-d Sep 11, 2025
d314db6
Fix CLI doc and typos.
Tim-ats-d Sep 25, 2025
11805ba
Clean up.
Tim-ats-d Sep 26, 2025
d3f6bdf
Add FIXME tests.
Tim-ats-d Sep 26, 2025
68b02e7
Fix PR nb.
Tim-ats-d Sep 30, 2025
fc8c063
Ensure minimality for refactor issue examples.
Tim-ats-d Oct 2, 2025
86cf319
Fix the path names in extractions
voodoos Oct 2, 2025
ee60e2d
Revert "Fix the path names in extractions"
voodoos Oct 2, 2025
9bb9388
Attempt #2 at fixing pathed param names
voodoos Oct 2, 2025
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
20 changes: 20 additions & 0 deletions tests/test-dirs/refactor-extract-region/extraction-issue.t/foo.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
let z = 100

let complicated_function x y =
let a = 10 in
let b = 11 in
let c = 12 in
let module D = struct
let x = 13
end in
a + b + (c * x * y) + z + D.x

let f () =
let module D = struct
let x = 42
end in
let module M = struct
let x = 1
end in
let a, b, c, x = (1, 2, 3, 4) in
a + b + c + D.x + x + M.(x + a)
77 changes: 77 additions & 0 deletions tests/test-dirs/refactor-extract-region/extraction-issue.t/run.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
FIXME: `x` is used instead of `d_x` in the extracted function body!
Should be: (((a + b) + ((c * x) * y)) + z) + d_x

$ $MERLIN single refactoring-extract-region -start 10:2 -end 10:31 < foo.ml
{
"class": "return",
"value": {
"start": {
"line": 3,
"col": 0
},
"end": {
"line": 10,
"col": 31
},
"content": "let fun_name1 x y a b c d_x = (((a + b) + ((c * x) * y)) + z) + x
Copy link
Collaborator

@voodoos voodoos Sep 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have mixed feelings about this. First, is this a minimal example ? Do you need a, b and c to trigger the issue ?
The more minimal the example is, when reproducing a precise error, the easier it will be to reason about for someone who would like to try and fix it later.

Also it feels like the fix would not be too hard... would it ?

let complicated_function x y =
let a = 10 in
let b = 11 in
let c = 12 in
let module D = struct
let x = 13
end in
(fun_name1 x y a b c D.x)",
"selection-range": {
"start": {
"line": 3,
"col": 4
},
"end": {
"line": 3,
"col": 13
}
}
},
"notifications": []
}

FIXME: the extracted function body is wrong.
Should be: a + b + c + d_x + x + (m_x + a)

$ $MERLIN single refactoring-extract-region -start 20:2 -end 20:33 < foo.ml
{
"class": "return",
"value": {
"start": {
"line": 12,
"col": 0
},
"end": {
"line": 20,
"col": 33
},
"content": "let fun_name1 a b c x d_x m_x =
((((a + b) + c) + x) + x) + (let open M in x + a)
let f () =
let module D = struct
let x = 42
end in
let module M = struct
let x = 1
end in
let a, b, c, x = (1, 2, 3, 4) in
(fun_name1 a b c x D.x M.x)",
"selection-range": {
"start": {
"line": 12,
"col": 4
},
"end": {
"line": 12,
"col": 13
}
}
},
"notifications": []
}
21 changes: 0 additions & 21 deletions tests/test-dirs/refactor-extract-region/func-extraction.t/func.ml
Original file line number Diff line number Diff line change
Expand Up @@ -156,24 +156,3 @@ module T = struct
let printer = pp_print_list pp_print_int in
printf "%a\n" printer a_list
end

let z = 100

let complicated_function x y =
let a = 10 in
let b = 11 in
let c = 12 in
let module D = struct
let x = 13
end in
a + b + (c * x * y) + z + D.x

let f () =
let module D = struct
let x = 42
end in
let module M = struct
let x = 1
end in
let a, b, c, x = (1, 2, 3, 4) in
a + b + c + D.x + x + M.(x + a)
37 changes: 0 additions & 37 deletions tests/test-dirs/refactor-extract-region/func-extraction.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -867,40 +867,3 @@ TODO: This extraction shouldn't be allowed.
},
"notifications": []
}

$ $MERLIN single refactoring-extract-region -start 169:2 -end 169:31 < func.ml
{
"class": "return",
"value": {
"start": {
"line": 162,
"col": 0
},
"end": {
"line": 169,
"col": 31
},
"content": "let fun_name2 x y a b c d_x = (((a + b) + ((c * x) * y)) + z) + d_x
let complicated_function x y =
let a = 10 in
let b = 11 in
let c = 12 in
let module D = struct
let x = 13
end in
(fun_name2 x y a b c D.x)",
"selection-range": {
"start": {
"line": 162,
"col": 4
},
"end": {
"line": 162,
"col": 13
}
}
},
"notifications": []
}

$ $MERLIN single refactoring-extract-region -start 179:2 -end 179:33 < func.ml
Loading