-
Notifications
You must be signed in to change notification settings - Fork 245
Add a new command to extract expression into a fresh let binding #1948
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
Open
Tim-ats-d
wants to merge
34
commits into
ocaml:main
Choose a base branch
from
Tim-ats-d:refactor-extraction
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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 a7a3729
Add a new command to extract expression into a fresh let binding.
Tim-ats-d 500487f
Merge branch 'main' into refactor-extraction
Tim-ats-d 1595bf4
Code quality.
Tim-ats-d d2d6e08
Add a function to determine if an expression is extractable inside a …
Tim-ats-d 38055ff
More tests.
Tim-ats-d f388319
Attempt to fix a bug with binding belonging to a module.
Tim-ats-d 1795632
Add change entry.
Tim-ats-d aee93b0
Add another test.
Tim-ats-d 7f90f47
Fix generation for parameter that appears twice, parenthised generat…
Tim-ats-d baedfc7
Code quality.
Tim-ats-d 3627558
Replace location heuristic by a proper analysis.
Tim-ats-d 195ed6d
Remove path of value living in a module inside extracted expression.
Tim-ats-d af58896
Make extraction works in submodule.
Tim-ats-d b064a8b
Clean up expression before printing.
Tim-ats-d f3db927
Generate a suffix when a name is given and already used in current sc…
Tim-ats-d 7551d2f
Fix a test.
Tim-ats-d d1d3c11
Take Ulysse's comments into account.
Tim-ats-d bc4e53d
Merge branch 'main' into refactor-extraction
Tim-ats-d c50af5b
Remove function type declaration.
Tim-ats-d 28a421e
Fix constant extraction nested in a modules.
Tim-ats-d 7fe97e7
Last fixes.
Tim-ats-d 32f03f0
WIP.
Tim-ats-d daf74d9
Reproduce a bug.
Tim-ats-d 7a00505
Merge branch 'state-of-work' into refactor-extraction
Tim-ats-d 3ec6dcc
Last fixes.
Tim-ats-d d314db6
Fix CLI doc and typos.
Tim-ats-d 11805ba
Clean up.
Tim-ats-d d3f6bdf
Add FIXME tests.
Tim-ats-d 68b02e7
Fix PR nb.
Tim-ats-d fc8c063
Ensure minimality for refactor issue examples.
Tim-ats-d 86cf319
Fix the path names in extractions
voodoos ee60e2d
Revert "Fix the path names in extractions"
voodoos 9bb9388
Attempt #2 at fixing pathed param names
voodoos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
tests/test-dirs/refactor-extract-region/extraction-issue.t/foo.ml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
77
tests/test-dirs/refactor-extract-region/extraction-issue.t/run.t
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| 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": [] | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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 ?