[Git][ghc/ghc][master] Use panic rather than error in expectJust
Marge Bot (@marge-bot)
gitlab at gitlab.haskell.org
Tue Mar 11 10:11:40 UTC 2025
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
589f40b9 by Matthew Pickering at 2025-03-11T06:11:11-04:00
Use panic rather than error in expectJust
Otherwise, we would not get a callstack printed out when the exception
occurs.
Fixes #25829
- - - - -
2 changed files:
- compiler/GHC/Data/Maybe.hs
- compiler/GHC/Utils/Panic.hs
Changes:
=====================================
compiler/GHC/Data/Maybe.hs
=====================================
@@ -34,6 +34,8 @@ import Control.Exception (SomeException(..))
import Data.Maybe
import Data.Foldable ( foldlM, for_ )
import GHC.Utils.Misc (HasCallStack)
+import GHC.Utils.Panic
+import GHC.Utils.Outputable
import Data.List.NonEmpty ( NonEmpty )
import Control.Applicative( Alternative( (<|>) ) )
@@ -72,7 +74,7 @@ expectJust :: HasCallStack => Maybe a -> a
expectJust = fromMaybe expectJustError
expectJustError :: HasCallStack => a
-expectJustError = error "expectJust"
+expectJustError = pprPanic "expectJust" empty
{-# NOINLINE expectJustError #-}
whenIsJust :: Monad m => Maybe a -> (a -> m ()) -> m ()
=====================================
compiler/GHC/Utils/Panic.hs
=====================================
@@ -188,7 +188,7 @@ handleGhcException = MC.handle
-- | Throw an exception saying "bug in GHC" with a callstack
pprPanic :: HasCallStack => String -> SDoc -> a
-pprPanic s doc = panicDoc s (doc $$ callStackDoc)
+pprPanic s doc = withFrozenCallStack $ panicDoc s (doc $$ callStackDoc)
-- | Throw an exception saying "bug in GHC"
panicDoc :: String -> SDoc -> a
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/589f40b9525c59d646a8b13cd51057bd350f7849
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/589f40b9525c59d646a8b13cd51057bd350f7849
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20250311/fa3a4549/attachment-0001.html>
More information about the ghc-commits
mailing list