RefactoringTools / HaRe

The Haskell Refactoring Tool
http://www.cs.kent.ac.uk/projects/refactor-fp/
Other
139 stars 32 forks source link

addOneParam issue #24

Open alanz opened 8 years ago

alanz commented 8 years ago
I wanted to try out hare from the command line and I have some "strange" results [22:46:53] actually I tried "rename" and "addOneParam" on a very simple function, but all that happened is the function definition get duplicated [22:47:42] @kmate, please provide details
kmate commented 8 years ago

Input in Test.hs:

module Test (f) where

g :: Double
g = 9.81

-- adds g to x
f x = x + g

Command line: cabal exec ghc-hare rename Test.hs h 7 1

Output in Test.refactored.hs:

module Test (f) where

g :: Double
g = 9.81

-- adds g to x
f x = x + g

-- adds g to x
h x = x + g

I expected that renaming a function will rewrite the export list and remove the old definition. Instead it duplicated the definition of f (cursor position 7,1).

kmate commented 8 years ago

Actually I tested on the master branch of my fork that contains no modifications yet.

kmate commented 8 years ago

Also when I want to rename g to h at cursor position 4,1 in the same input file, the definition of g will be duplicated as h, and the reference to g in the body of f also remains unchanged.

kmate commented 8 years ago

Maybe I am misusing something because executing addOneParam instead of rename gives exactly the same results.

alanz commented 8 years ago

Thanks, I will set up a test case.

On Fri, Feb 19, 2016 at 5:56 PM, Karácsony Máté notifications@github.com wrote:

Also when I want to rename g to h at cursor position 4,1 in the same input file, the definition of g will be duplicated as h, and the reference to g in the body of f also remains unchanged.

— Reply to this email directly or view it on GitHub https://github.com/RefactoringTools/HaRe/issues/24#issuecomment-186275370 .

alanz commented 8 years ago

The CLI driver was recently changed in master, it sounds like it is doing a dupDef, maybe that is the problem.

There is not currently a set of tests calling the exe to check the CLI invocation

On Fri, Feb 19, 2016 at 5:58 PM, Karácsony Máté notifications@github.com wrote:

Maybe I am misusing something because executing addOneParam instead of rename gives exactly the same results.

— Reply to this email directly or view it on GitHub https://github.com/RefactoringTools/HaRe/issues/24#issuecomment-186276068 .

alanz commented 8 years ago

Yes, see

https://github.com/alanz/HaRe/blob/master/src/MainHaRe.hs#L168

On Fri, Feb 19, 2016 at 6:07 PM, Alan & Kim Zimmerman alan.zimm@gmail.com wrote:

The CLI driver was recently changed in master, it sounds like it is doing a dupDef, maybe that is the problem.

There is not currently a set of tests calling the exe to check the CLI invocation

On Fri, Feb 19, 2016 at 5:58 PM, Karácsony Máté notifications@github.com wrote:

Maybe I am misusing something because executing addOneParam instead of rename gives exactly the same results.

— Reply to this email directly or view it on GitHub https://github.com/RefactoringTools/HaRe/issues/24#issuecomment-186276068 .

kmate commented 8 years ago

Yes, and also here:

https://github.com/alanz/HaRe/blob/master/src/MainHaRe.hs#L148

alanz commented 8 years ago

PR's cheerfully accepted here :)

kmate commented 8 years ago

Done, see #25. Now it works as expected :)