Skip to content

Commit

Permalink
Fix last roundtrip test based on re-inserting comments
Browse files Browse the repository at this point in the history
  • Loading branch information
alanz committed Apr 7, 2024
1 parent 0384cb4 commit 923bc87
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
9 changes: 4 additions & 5 deletions src/Language/Haskell/GHC/ExactPrint/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ insertTopLevelCppComments (HsModule (XModulePs an lo mdeprec mbDoc) mmn mexports
(remaining, these) =
case entry l of
EpaSpan (RealSrcSpan s _) -> do
allocatePriorComments s cs
allocatePriorComments (ss2posEnd s) cs
_ -> (cs, [])

(EpAnn a anno ocs) = an :: EpAnn AnnsModule
Expand Down Expand Up @@ -334,18 +334,17 @@ insertTopLevelCppComments (HsModule (XModulePs an lo mdeprec mbDoc) mmn mexports
(rest, these) =
case anc4 of
EpaSpan (RealSrcSpan s _) ->
allocatePriorComments s cs'
allocatePriorComments (ss2pos s) cs'
_ -> (cs', [])
cs4' = workInComments cs4 these
(xs',rest') = allocPreceding xs rest

allocatePriorComments
:: RealSrcSpan
:: Pos
-> [LEpaComment]
-> ([LEpaComment], [LEpaComment])
allocatePriorComments ss comment_q =
allocatePriorComments ss_loc comment_q =
let
ss_loc = ss2pos ss
cmp (L l _) = ss2pos (anchor l) <= ss_loc
(newAnns,after) = partition cmp comment_q
in
Expand Down
4 changes: 2 additions & 2 deletions tests/Test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,9 @@ tt' = do
-- mkParserTestMD libdir "ghc80" "ForFree.hs"

-- Current failures (roundtrip only)
mkParserTest libdir "ghc710" "Stmts.hs"
-- mkParserTest libdir "ghc710" "Stmts.hs"
-- mkParserTest libdir "ghc80" "ForFree.hs"
-- "ContinuationIO.hs"
mkParserTest libdir "ghc96" "ContinuationIO.hs"

-- Needs GHC changes

Expand Down

0 comments on commit 923bc87

Please sign in to comment.