From 1418869f06169e7fddc167719fbf8b9421ec4283 Mon Sep 17 00:00:00 2001
From: Ben Gamari <bgamari.foss@gmail.com>
Date: Tue, 11 Jun 2024 15:43:19 +0000
Subject: [PATCH] base: Add `HasCallStack` constraint to `ioError`

As proposed in core-libraries-committee#275.

(cherry picked from commit 876d6e0e807c074d5c71370aa3c3451bbcb28342)
---
 libraries/base/changelog.md                             | 1 +
 libraries/ghc-internal/src/GHC/Internal/IO/Exception.hs | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/libraries/base/changelog.md b/libraries/base/changelog.md
index 7e96beff96a..6f7b07ef0c5 100644
--- a/libraries/base/changelog.md
+++ b/libraries/base/changelog.md
@@ -15,6 +15,7 @@
   * Add `inits1` and `tails1` to `Data.List`, factored from the corresponding functions in `Data.List.NonEmpty` ([CLC proposal #252](https://github.com/haskell/core-libraries-committee/issues/252))
   * Add `firstA` and `secondA` to `Data.Bitraversable`. ([CLC proposal #172](https://github.com/haskell/core-libraries-committee/issues/172))
   * Deprecate `GHC.TypeNats.Internal`, `GHC.TypeLits.Internal`, `GHC.ExecutionStack.Internal` ([CLC proposal #217](https://github.com/haskell/core-libraries-committee/issues/217))
+  * `System.IO.Error.ioError` and `Control.Exception.ioError` now both carry `HasCallStack` constraints ([CLC proposal #275](https://github.com/haskell/core-libraries-committee/issues/275))
   * Define `Eq1`, `Ord1`, `Show1` and `Read1` instances for basic `Generic` representation types. ([CLC proposal #273](https://github.com/haskell/core-libraries-committee/issues/273))
   * `setNonBlockingMode` will no longer throw an exception when called on a FD associated with a unknown device type. ([CLC proposal #282](https://github.com/haskell/core-libraries-committee/issues/282))
   * Add exception type metadata to default exception handler output.
diff --git a/libraries/ghc-internal/src/GHC/Internal/IO/Exception.hs b/libraries/ghc-internal/src/GHC/Internal/IO/Exception.hs
index fca56e22d50..7e9e8b009b0 100644
--- a/libraries/ghc-internal/src/GHC/Internal/IO/Exception.hs
+++ b/libraries/ghc-internal/src/GHC/Internal/IO/Exception.hs
@@ -315,8 +315,8 @@ ioException     :: HasCallStack => IOException -> IO a
 ioException err = throwIO err
 
 -- | Raise an 'IOError' in the 'IO' monad.
-ioError         :: IOError -> IO a
-ioError         =  ioException
+ioError         :: HasCallStack => IOError -> IO a
+ioError err     =  ioException err
 
 -- ---------------------------------------------------------------------------
 -- IOError type
-- 
GitLab