Skip to content

Commit

Permalink
Works with my current GHC 9.10 backport branch
Browse files Browse the repository at this point in the history
  • Loading branch information
alanz committed Apr 18, 2024
1 parent 0dd1aad commit b7d7650
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 35 deletions.
11 changes: 6 additions & 5 deletions NEW-GHC.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Change to the current GHC git repository (for the new version of GHC)

$ mkdir /tmp/ghc-tests
$ export DESTINATION=/tmp/ghc-tests
$ export PREVIOUS=ghc-9.6
$ export PREVIOUS=ghc-9.8

Sanity check

Expand All @@ -27,8 +27,8 @@ tests. Generally remove any `should_fail` directory.

In the ghc-exactprint directory

$ mkdir tests/examples/ghc98-copied
$ find /tmp/ghc-tests -iname "*.hs" | xargs cp --backup=numbered -t ./tests/examples/ghc98-copied/
$ mkdir tests/examples/ghc910-copied
$ find /tmp/ghc-tests -iname "*.hs" | xargs cp --backup=numbered -t ./tests/examples/ghc910-copied/

Note: there is a pathological file `parsing001.hs`, which should be deleted

Expand All @@ -40,13 +40,14 @@ extension.
You may need to do `apt-get install mmv` first.
See http://manpages.ubuntu.com/manpages/zesty/en/man1/mmv.1.html

$ cd tests/examples/ghc98-copied
$ cd tests/examples/ghc910-copied
$ mmv "*.hs.~*~" "#1.#2.hs"

### cleanup whitespace in the files

$ cd tests/examples/ghc96-copied
$ cd tests/examples/ghc910-copied
$ ../../../emacs-ws-cleanup.sh
$ rm *~ # get rid of emacs backup files


### capture the failures
Expand Down
36 changes: 33 additions & 3 deletions src/Language/Haskell/GHC/ExactPrint/ExactPrint.hs
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,7 @@ markArrow (HsExplicitMult (pct, arr) t) = do
arr' <- markEpUniToken arr
return (HsExplicitMult (pct', arr') t')


-- ---------------------------------------------------------------------

markAnnCloseP :: (Monad m, Monoid w) => EpAnn AnnPragma -> EP w m (EpAnn AnnPragma)
Expand Down Expand Up @@ -2513,15 +2514,29 @@ instance ExactPrint (HsBind GhcPs) where
return (FunBind x fun_id' matches')

exact (PatBind x pat q grhss) = do
q' <- markAnnotated q
pat' <- markAnnotated pat
grhss' <- markAnnotated grhss
return (PatBind x pat' q grhss')
return (PatBind x pat' q' grhss')
exact (PatSynBind x bind) = do
bind' <- markAnnotated bind
return (PatSynBind x bind')

exact x = error $ "HsBind: exact for " ++ showAst x

instance ExactPrint (HsMultAnn GhcPs) where
getAnnotationEntry _ = NoEntryVal
setAnnotationAnchor a _ _ _ = a

exact (HsNoMultAnn x) = return (HsNoMultAnn x)
exact (HsPct1Ann tok) = do
tok' <- markEpToken tok
return (HsPct1Ann tok')
exact (HsMultAnn tok ty) = do
tok' <- markEpToken tok
ty' <- markAnnotated ty
return (HsMultAnn tok' ty')

-- ---------------------------------------------------------------------

instance ExactPrint (PatSynBind GhcPs GhcPs) where
Expand Down Expand Up @@ -2839,15 +2854,16 @@ instance ExactPrint (Sig GhcPs) where
(an0, vars',ty') <- exactVarSig an vars ty
return (ClassOpSig an0 is_deflt vars' ty')

exact (FixSig an (FixitySig x names (Fixity src v fdir))) = do
exact (FixSig an (FixitySig ns names (Fixity src v fdir))) = do
let fixstr = case fdir of
InfixL -> "infixl"
InfixR -> "infixr"
InfixN -> "infix"
an0 <- markEpAnnLMS'' an lidl AnnInfix (Just fixstr)
an1 <- markEpAnnLMS'' an0 lidl AnnVal (Just (sourceTextToString src (show v)))
ns' <- markAnnotated ns
names' <- markAnnotated names
return (FixSig an1 (FixitySig x names' (Fixity src v fdir)))
return (FixSig an1 (FixitySig ns' names' (Fixity src v fdir)))

exact (InlineSig an ln inl) = do
an0 <- markAnnOpen an (inl_src inl) "{-# INLINE"
Expand Down Expand Up @@ -2900,6 +2916,20 @@ instance ExactPrint (Sig GhcPs) where

-- ---------------------------------------------------------------------

instance ExactPrint NamespaceSpecifier where
getAnnotationEntry _ = NoEntryVal
setAnnotationAnchor a _ _ _ = a

exact NoNamespaceSpecifier = return NoNamespaceSpecifier
exact (TypeNamespaceSpecifier typeTok) = do
typeTok' <- markEpToken typeTok
return (TypeNamespaceSpecifier typeTok')
exact (DataNamespaceSpecifier dataTok) = do
dataTok' <- markEpToken dataTok
return (DataNamespaceSpecifier dataTok')

-- ---------------------------------------------------------------------

exactVarSig :: (Monad m, Monoid w, ExactPrint a)
=> AnnSig -> [LocatedN RdrName] -> a -> EP w m (AnnSig, [LocatedN RdrName], a)
exactVarSig an vars ty = do
Expand Down
33 changes: 6 additions & 27 deletions tests/Test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ testDirs =
case ghcVersion of
GHC98 -> ["ghc710", "ghc80", "ghc82", "ghc84", "ghc86", "ghc88", "ghc810", "ghc90", "ghc92", "ghc94", "ghc96"]
GHC910 -> ["ghc710", "ghc80", "ghc82", "ghc84", "ghc86", "ghc88", "ghc810", "ghc90", "ghc92", "ghc94", "ghc96", "ghc98"]
-- GHC98 -> ["ghc98"]
-- GHC98 -> ["ghc98-copied"]
-- GHC910 -> ["ghc910"]
-- GHC910 -> ["ghc910-copied"]
-- GHC910 -> ["ghc910", "ghc910-copied"]

-- ---------------------------------------------------------------------

Expand Down Expand Up @@ -198,38 +199,16 @@ tt' = do
let libdir = GHC.Paths.libdir
runTestText (putTextToHandle stdout True) $ TestList [

-- mkParserTest libdir "ghc710" "Expr.hs"
-- mkParserTestMD libdir "ghc710" "Expr.hs"

-- mkParserTest libdir "ghc98" "ModuleComments1.hs"
-- mkParserTestBC libdir "ghc98" "MonoidsFD1.hs"
-- mkParserTestMD libdir "ghc98" "ModuleComments1.hs"

-- mkParserTest libdir "ghc98" "ModuleComments2.hs"
-- mkParserTestMD libdir "ghc98" "ModuleComments2.hs"

-- mkParserTest libdir "ghc98" "ModuleComments3.hs"
mkParserTestMD libdir "ghc98" "ModuleComments3.hs"


-- mkParserTest libdir "ghc80" "ForFree.hs"
-- mkParserTestMD libdir "ghc80" "ForFree.hs"

-- mkParserTest libdir "transform" "WhereIn3b.hs"
-- mkParserTest libdir "ghc710" "EmptyMostlyTrailing.hs"
-- mkParserTest libdir "ghc710" "Undefined10a.hs"

-- mkParserTest libdir "ghc710" "CExpected1.hs"
-- mkParserTestMD libdir "ghc710" "CExpected1.hs"

-- ExportWarnings_aux.hs
-- ghc98:7:T23465.hs
-- mkParserTest libdir "ghc910" "LinearLet.hs"
mkParserTest libdir "ghc910" "T8761.hs"
-- mkParserTestMD libdir "ghc710" "AnnotationNoListTuplePuns.hs"

-- Needs GHC changes

-- Epalocation needed in WarningTxt
-- mkParserTest libdir "ghc80" "DeprM.hs"
-- mkParserTestMD libdir "ghc80" "DeprM.hs"


]
Expand Down

0 comments on commit b7d7650

Please sign in to comment.