Skip to content

Refactors across comments yield invalid code #1643

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
ysangkok opened this issue Apr 20, 2025 · 0 comments
Open

Refactors across comments yield invalid code #1643

ysangkok opened this issue Apr 20, 2025 · 0 comments

Comments

@ysangkok
Copy link
Contributor

Unsure whether this is an hlint or apply-refact bug, so I am reporting it here, extracted from #1642.

It looks related to

Using apply-refact from git, and hlint from git, on GHC 9.12.2 with a Hackage index from today.

Main.hs:

main = id $
  -- Hello world
  pure ()
% hlint --serialise Main.hs | tee refactors
[( "Main.hs:(1,8)-(3,9): Warning: Redundant id\nFound:\n  id $ pure ()\nPerhaps:\n  pure ()\n"
 , [Replace
       { rtype = Expr
       , pos = SrcSpan
          { startLine = 1
          , startCol = 8
          , endLine = 3
          , endCol = 10 }
       , subts = [("x",SrcSpan {startLine = 3, startCol = 3, endLine = 3, endCol = 10})]
       , orig = "x"}])]
% refactor --refact-file refactors Main.hs
Applying 1 hints
main =
  -- Hello world pure ()

This is an invalid program now, since there is no expression on the rhs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant