summaryrefslogtreecommitdiff
path: root/libraries/base/Control
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2022-12-19 17:48:38 +0000
committerMatthew Pickering <matthewtpickering@gmail.com>2022-12-22 07:18:28 +0000
commit6810c15e71cc9f3c590f4c37c37e35d1fd8009d1 (patch)
tree1777ebbf2c62a90ea776fc0efe106d83b03734fd /libraries/base/Control
parent3d55d8ab51ece43c51055c43c9e7aba77cce46c0 (diff)
downloadhaskell-wip/T22634.tar.gz
Refactor mkRuntimeErrorwip/T22634
This patch fixes #22634. Because we don't have TYPE/CONSTRAINT polymorphism, we need two error functions rather than one. I took the opportunity to rname runtimeError to impossibleError, to line up with mkImpossibleExpr, and avoid confusion with the genuine runtime-error-constructing functions.
Diffstat (limited to 'libraries/base/Control')
-rw-r--r--libraries/base/Control/Exception/Base.hs17
1 files changed, 11 insertions, 6 deletions
diff --git a/libraries/base/Control/Exception/Base.hs b/libraries/base/Control/Exception/Base.hs
index c2c675c65d..06ae041624 100644
--- a/libraries/base/Control/Exception/Base.hs
+++ b/libraries/base/Control/Exception/Base.hs
@@ -94,7 +94,8 @@ module Control.Exception.Base (
finally,
-- * Calls for GHC runtime
- recSelError, recConError, runtimeError,
+ recSelError, recConError,
+ impossibleError, impossibleConstraintError,
nonExhaustiveGuardsError, patError, noMethodBindingError,
typeError,
nonTermination, nestedAtomically, noMatchingContinuationPrompt,
@@ -409,21 +410,25 @@ instance Exception NoMatchingContinuationPrompt
-----
-- See Note [Compiler error functions] in ghc-prim:GHC.Prim.Panic
-recSelError, recConError, runtimeError,
- nonExhaustiveGuardsError, patError, noMethodBindingError,
- typeError
+recSelError, recConError, typeError,
+ nonExhaustiveGuardsError, patError, noMethodBindingError
:: Addr# -> a -- All take a UTF8-encoded C string
recSelError s = throw (RecSelError ("No match in record selector "
++ unpackCStringUtf8# s)) -- No location info unfortunately
-runtimeError s = errorWithoutStackTrace (unpackCStringUtf8# s) -- No location info unfortunately
-
nonExhaustiveGuardsError s = throw (PatternMatchFail (untangle s "Non-exhaustive guards in"))
recConError s = throw (RecConError (untangle s "Missing field in record construction"))
noMethodBindingError s = throw (NoMethodError (untangle s "No instance nor default method for class operation"))
patError s = throw (PatternMatchFail (untangle s "Non-exhaustive patterns in"))
typeError s = throw (TypeError (unpackCStringUtf8# s))
+
+impossibleError, impossibleConstraintError :: Addr# -> a
+-- These two are used for impossible case alternatives, and lack location info
+impossibleError s = errorWithoutStackTrace (unpackCStringUtf8# s)
+impossibleConstraintError s = errorWithoutStackTrace (unpackCStringUtf8# s)
+
+
-- GHC's RTS calls this
nonTermination :: SomeException
nonTermination = toException NonTermination