Skip to content

Refactors across comments yield invalid code #1643

Description

@ysangkok

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.

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions