Skip to content

Commit

Permalink
fix backwards compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
HugoPeters1024 committed Sep 13, 2022
1 parent 96bac54 commit 37dcc97
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 3 additions & 0 deletions ghc-dump-core/GhcDump/Ast.hs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ instance Serialise TyCon
data TyLit = NumTyLit Int
| StrTyLit T.Text
| CharTyLit Char
-- TyLit did not always exist, we weaken the definition
-- with this constructor for backwards compatibility.
| UnknownLit
deriving (Eq, Ord, Generic, Show)
instance Serialise TyLit

Expand Down
10 changes: 8 additions & 2 deletions ghc-dump-core/GhcDump/Convert.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ module GhcDump.Convert (cvtModule) where
import Data.Bifunctor
import qualified Data.Text as T
import qualified Data.Text.Encoding as TE
import GHC.Data.FastString (unpackFS)

#if MIN_VERSION_ghc(9,0,0)
import GHC.Types.Literal (Literal(..))
Expand Down Expand Up @@ -342,10 +341,17 @@ cvtModule' phaseId phase guts =
cvtModuleName :: HasEnv => Module.ModuleName -> Ast.ModuleName
cvtModuleName = Ast.ModuleName . fastStringToText . moduleNameFS

#if MIN_VERSION_ghc(9,0,0)
cvtTyLit :: HasEnv => Type.TyLit -> Ast.TyLit
cvtTyLit (Type.NumTyLit n) = (Ast.NumTyLit (fromIntegral n))
cvtTyLit (Type.StrTyLit s) = (Ast.StrTyLit (T.pack (unpackFS s)))
cvtTyLit (Type.StrTyLit s) = (Ast.StrTyLit (T.pack (FastString.unpackFS s)))
#if MIN_VERSION_ghc(9,2,0)
cvtTyLit (Type.CharTyLit c) = (Ast.CharTyLit c)
#endif
#else
cvtTyLit :: HasEnv => a -> Ast.TyLit
cvtTyLit _ = Ast.UnknownLit
#endif

cvtType :: HasEnv => Type.Type -> Ast.SType
#if MIN_VERSION_ghc(9,0,0)
Expand Down

0 comments on commit 37dcc97

Please sign in to comment.