From 7725a21a49b719544d60d832662b07277f1e158e Mon Sep 17 00:00:00 2001 From: Sylvain Henry Date: Wed, 31 Jul 2024 10:27:49 +0200 Subject: [PATCH] GHC 9.10: disable error index links when printing exceptions. --- src/GhcUtil.hs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/GhcUtil.hs b/src/GhcUtil.hs index 653549f7..91a64bc6 100644 --- a/src/GhcUtil.hs +++ b/src/GhcUtil.hs @@ -29,6 +29,10 @@ import System.Exit (exitFailure) import StaticFlags (discardStaticFlags) #endif +#if __GLASGOW_HASKELL__ >= 910 +import GHC.Data.Bool (OverridingBool(..)) +#endif + -- Catch GHC source errors, print them and exit. handleSrcErrors :: Ghc a -> Ghc a handleSrcErrors action' = flip handleSourceError action' $ \err -> do @@ -58,7 +62,18 @@ handleDynamicFlags flags = do #else let parseDynamicFlags' = parseDynamicFlags #endif - (dynflags, locSrcs, _) <- (setHaddockMode `fmap` getSessionDynFlags) >>= (`parseDynamicFlags'` flags) + (dynflags', locSrcs, _) <- (setHaddockMode `fmap` getSessionDynFlags) >>= (`parseDynamicFlags'` flags) + +#if __GLASGOW_HASKELL__ >= 910 + -- never display error links when displaying exception. Otherwise we get + -- failures like this: + -- expected: "Foo.hs:6:1: error: [GHC-58481]\n parse error..." + -- but got: "Foo.hs:6:1: error: [\ESC]8;;https://errors.haskell.org/messages/GHC-58481\ESC\\GHC-58481\ESC]8;;\ESC\\]\n parse error..." + let dynflags = dynflags' { useErrorLinks = Never } +#else + let dynflags = dynflags' +#endif + _ <- setSessionDynFlags dynflags -- We basically do the same thing as `ghc/Main.hs` to distinguish