Closed
Description
Your environment
Which OS do you use?
Fedora
Which version of GHC do you use and how did you install it?
9.6.2 from ghcup
How is your project built (alternative: link to the project)?
Which LSP client (editor/plugin) do you use?
vim+coc.nvim
Which version of HLS do you use and how did you install it?
Have you configured HLS in any way (especially: a hie.yaml
file)?
no
Steps to reproduce
Use the following file
module X where
data X a where
X :: X Int
Y :: X String
Z :: X Int
a :: X Int
a = X
-- this doesn't type check on purpose:
instance Eq X where
(==) = \_ _ -> True
Try to rename the X
data type to X'
.
Expected behaviour
Either nothing should be changed or everything even in presence of type errors.
Actual behaviour
module X where
data X a where
X :: X Int
Y :: X String
Z :: X Int
a :: X Int
a = X
-- this doesn't type check on purpose:
instance Eq X' where
(==) = \_ _ -> True
i.e. non of the X
occurrences in the defintiion of X
or a
changed, only its occurrence in the Eq
instance.
Activity
fendor commentedon Sep 10, 2023
Hi, thank you for your bug report!
Likely, the rename handler uses
useWithStale
, causing it to fall back to the latest compiling file state.I agree, renaming doesn't make sense if the module doesn't compile. I think, we should have two modi, for local renames only, we require that the module we look at compiles, for cross module renaming, the whole project needs to compile successfully.
This should be simple enough to fix in https://github.com/haskell/haskell-language-server/blob/master/plugins/hls-rename-plugin/src/Ide/Plugin/Rename.hs#L232. Instead of
useWithStaleE
, preferuseE
.Likely, we need something like
getNamesAtPoint
but without any PositionMapping.Rename only if the current module compiles (haskell#3799)
Rename only if the current module compiles (haskell#3799)
Rename only if the current module compiles (haskell#3799)
Rename only if the current module compiles (haskell#3799)
Rename only if the current module compiles (haskell#3799)
Rename only if the current module compiles (#3799) (#3848)
Rename only if the current module compiles (#3799) (#3848)