diff --git a/ghc-parser/generic-src/Language/Haskell/GHC/Parser.hs b/ghc-parser/generic-src/Language/Haskell/GHC/Parser.hs index 1b575cf5..73622988 100644 --- a/ghc-parser/generic-src/Language/Haskell/GHC/Parser.hs +++ b/ghc-parser/generic-src/Language/Haskell/GHC/Parser.hs @@ -29,7 +29,16 @@ module Language.Haskell.GHC.Parser ( import Data.List (intercalate, findIndex, isInfixOf) import Data.Char (isAlphaNum) -#if MIN_VERSION_ghc(9,8,0) +#if MIN_VERSION_ghc(9,14,0) +import GHC.Driver.Config.Parser (initParserOpts) +import GHC.Driver.Session (supportedLanguagesAndExtensions) +import GHC.Parser.Errors.Types (PsMessage(..)) +import GHC.Platform (platformArchOS) +import GHC.Types.Error (defaultDiagnosticOpts, getMessages, MsgEnvelope(..)) +import GHC.Utils.Error (diagnosticMessage, formatBulleted) +import GHC.Utils.Logger (initLogger) +import GHC.Utils.Outputable (defaultSDocContext, renderWithContext) +#elif MIN_VERSION_ghc(9,8,0) import GHC.Driver.Config.Parser (initParserOpts) import GHC.Parser.Errors.Types (PsMessage(..)) import GHC.Types.Error (defaultDiagnosticOpts, getMessages, MsgEnvelope(..)) @@ -215,12 +224,19 @@ runParser flags (Parser parser) str = parsePragmasIntoDynFlags :: DynFlags -> FilePath -> String -> IO (Maybe DynFlags) parsePragmasIntoDynFlags flags filepath str = catchErrors $ do -#if MIN_VERSION_ghc(9,4,0) +#if MIN_VERSION_ghc(9,14,0) + -- GHC 9.14 made getOptions take the supported pragmas and parseDynamicFilePragma take a Logger. + let supported = supportedLanguagesAndExtensions (platformArchOS (targetPlatform flags)) + let opts = snd $ getOptions (initParserOpts flags) supported (stringToStringBuffer str) filepath + logger <- initLogger + (flags', _, _) <- parseDynamicFilePragma logger flags opts +#elif MIN_VERSION_ghc(9,4,0) let opts = snd $ getOptions (initParserOpts flags) (stringToStringBuffer str) filepath + (flags', _, _) <- parseDynamicFilePragma flags opts #else let opts = getOptions flags (stringToStringBuffer str) filepath -#endif (flags', _, _) <- parseDynamicFilePragma flags opts +#endif return $ Just flags' where catchErrors :: IO (Maybe DynFlags) -> IO (Maybe DynFlags) diff --git a/ghc-parser/ghc-parser.cabal b/ghc-parser/ghc-parser.cabal index c6727a61..78cb47fd 100644 --- a/ghc-parser/ghc-parser.cabal +++ b/ghc-parser/ghc-parser.cabal @@ -23,7 +23,7 @@ library -- other-modules: -- other-extensions: build-depends: base >=4.9 && < 5, - ghc >=8.4 && <9.14 + ghc >=8.4 && <9.16 if impl(ghc >= 8.4) && impl(ghc < 8.10) hs-source-dirs: generic-src src-8.4 @@ -37,7 +37,7 @@ library hs-source-dirs: generic-src src-9.4 if impl(ghc >= 9.6) && impl(ghc < 9.8) hs-source-dirs: generic-src src-9.6 - if impl(ghc >= 9.8) && impl(ghc < 9.14) + if impl(ghc >= 9.8) && impl(ghc < 9.16) hs-source-dirs: generic-src src-9.8 diff --git a/ihaskell.cabal b/ihaskell.cabal index e2b12411..72f36707 100644 --- a/ihaskell.cabal +++ b/ihaskell.cabal @@ -71,7 +71,7 @@ library bytestring , exceptions , filepath , - ghc >=8.4 && <9.13, + ghc >=8.4 && <9.16, ghc-boot , haskeline , parsec , diff --git a/src/IHaskell/Eval/Evaluate.hs b/src/IHaskell/Eval/Evaluate.hs index 93bfcfed..0bb71687 100644 --- a/src/IHaskell/Eval/Evaluate.hs +++ b/src/IHaskell/Eval/Evaluate.hs @@ -637,7 +637,12 @@ evalCommand _ (Module contents) state = wrapExecution state $ do -- Get the dot-delimited pieces of the module name. moduleNameOf :: InteractiveImport -> [String] moduleNameOf (IIDecl decl) = split "." . moduleNameString . unLoc . ideclName $ decl +#if MIN_VERSION_ghc(9,14,0) + -- GHC 9.14 changed IIModule to carry a Module rather than a ModuleName. + moduleNameOf (IIModule imp) = split "." . moduleNameString . moduleName $ imp +#else moduleNameOf (IIModule imp) = split "." . moduleNameString $ imp +#endif -- Return whether this module prevents the loading of the one we're trying to load. If a module B -- exist, we cannot load A.B. All modules must have unique last names (where A.B has last name B). diff --git a/src/IHaskell/Eval/Util.hs b/src/IHaskell/Eval/Util.hs index c975d0a7..89f0c6e1 100644 --- a/src/IHaskell/Eval/Util.hs +++ b/src/IHaskell/Eval/Util.hs @@ -497,7 +497,12 @@ removeImport modName = do where isImportOf :: ModuleName -> InteractiveImport -> Bool +#if MIN_VERSION_ghc(9,14,0) + -- GHC 9.14 changed IIModule to carry a Module rather than a ModuleName. + isImportOf name (IIModule m) = name == moduleName m +#else isImportOf name (IIModule mName) = name == mName +#endif isImportOf name (IIDecl impDecl) = name == unLoc (ideclName impDecl) -- | Evaluate a series of declarations. Return all names which were bound by these declarations.