rikvdkleij / intellij-haskell

IntelliJ plugin for Haskell
https://rikvdkleij.github.io/intellij-haskell/
Apache License 2.0
1.31k stars 94 forks source link

Occasionally, applying hlint suggestions doesn't work as expected #602

Open L7R7 opened 4 years ago

L7R7 commented 4 years ago

Since the latest beta (?) applying hlint suggestions doesn't always work. There are some cases where it does work, and others where the suggestion is inserted without overriding existing code. Here's a sample:

sample :: [Int] -> (Int -> Int) -> [String]
sample xs f = (show . f) <$> xs

IntelliJ offers me a quick fix saying:

Reudundant bracket, change to show . f <$> xs

when I apply the fix, I end up with the following:

sample xs f = show . f <$> xs <$> xs

So, it doesn't override <$> xs but inserts it (similar to when I press Enter instead of Tab for completion).

My guess is that it is related to when there are a function composition operator and redundant brackets involved, but I'm not sure about that.

I'm on plugin version 1.0.0-beta78, IntellIJ IDEA 2020.2.1 RC (Ultimate Edition) Build #IU-202.6948.36 (I faced the issue with 2020.2 as well)

rikvdkleij commented 4 years ago

Thanks for reporting!

Would be helpful to have more cases which go wrong.

L7R7 commented 4 years ago

Ok, I'll try to collect more cases

L7R7 commented 4 years ago

the quick fix doesn't change anything here (it suggests (show . f), I would expect another fix after that that results in the same as above)

sample :: [Int] -> (Int -> Int) -> [String]
sample xs f = ((show . f)) <$> xs
L7R7 commented 4 years ago
blabla = (\header -> (fst header) == privateToken)

removing the outer brackets work. Removing the brackets around fst header doesn't:

blabla = \ header -> fst header == privateToken == privateToken
rikvdkleij commented 4 years ago

Investigated this issue and to solve this properly I have to change the integration with HLint. Will take some effort but it's necessary.

rikvdkleij commented 3 years ago

Should be fixed in beta85, https://github.com/rikvdkleij/intellij-haskell/releases/tag/v1.0.0-beta85

rikvdkleij commented 3 years ago

@L7R7 Are your HLint issues solved?

L7R7 commented 3 years ago

I totally missed the notifications on this issue, sorry for letting you wait! I just downloaded beta85 and tried it. I can tell that it definitely got better. The fixes for my first examples work now (the sample function ones). However, the last one is still a bit weird. For this one:

blabla = (\header -> (fst header) == "privateToken")

I get three suggestions (two redundant brackets and one redundant lambda). The fixes for brackets work, but when I apply the fix for the redundant lambda I get:

blheaderblheader header = (fst heheaderder) == "privheaderteToken"

Interestingly, the suggestion in the popup is weird already: image

I get the same behavior even when I apply the fixes for the brackets first

rikvdkleij commented 3 years ago

Thanks! Will take a look to this case soon.