Magnus pushed to branch wip/mangoiv/9.12.5-rc4 at Glasgow Haskell Compiler / GHC
Commits:
-
d750a543
by Ben Gamari at 2026-09-04T16:43:06+02:00
5 changed files:
- + changelog.d/T27455
- libraries/base/changelog.md
- libraries/ghc-internal/src/GHC/Internal/Exception/Type.hs
- testsuite/tests/ghc-e/should_fail/T18441fail7.stderr
- testsuite/tests/ghc-e/should_run/ghc-e005.stderr
Changes:
| 1 | +section: base
|
|
| 2 | +issues: #27455
|
|
| 3 | +mrs: !16274
|
|
| 4 | +synopsis:
|
|
| 5 | + Don't drop `ExceptionContext` in `SomeException(toException)`
|
|
| 6 | +description:
|
|
| 7 | + Previously the implementation of ``Exception(toException)`` given to `SomeException` would inappropriately drop the carried `ExceptionContext`. Now ``toException = id``, faithfully implementing the semantics proposed in :ref:`CLC Proposal #200 <https://github.com/haskell/core-libraries-committee/issues/200>`.
|
|
| 8 | + |
| ... | ... | @@ -2,6 +2,8 @@ |
| 2 | 2 | |
| 3 | 3 | ## 4.21.3.0 *June 2026*
|
| 4 | 4 | * System.Info.fullCompilerVersion: add 'since' annotation
|
| 5 | + * The implementation of `toException` in `SomeException`'s `Exception` instance no longer drops exception context, in keeping with the behavior originally proposed in [CLC Proposal #200](https://github.com/haskell/core-libraries-committee/issues/200).
|
|
| 6 | + |
|
| 5 | 7 | |
| 6 | 8 | ## 4.21.2.0 *March 2026*
|
| 7 | 9 | * Expose `Backtraces` constructor and fields ([CLC proposal #199](https://github.com/haskell/core-libraries-committee/issues/199), [#26049](https://gitlab.haskell.org/ghc/ghc/-/issues/26049))
|
| ... | ... | @@ -206,7 +206,16 @@ Caught MismatchedParentheses |
| 206 | 206 | |
| 207 | 207 | -}
|
| 208 | 208 | class (Typeable e, Show e) => Exception e where
|
| 209 | - -- | @toException@ should produce a 'SomeException' with no attached 'ExceptionContext'.
|
|
| 209 | + -- | 'toException' converts an exception into the existential 'SomeException'
|
|
| 210 | + -- wrapper type.
|
|
| 211 | + --
|
|
| 212 | + -- In doing so, 'toException' should not /add/ an 'ExceptionContext'.
|
|
| 213 | + --
|
|
| 214 | + -- - In most cases, the exception does not store its own 'ExceptionContext'.
|
|
| 215 | + -- The default implementation of 'toException' (which does not store any
|
|
| 216 | + -- 'ExceptionContext') is suitable for these cases.
|
|
| 217 | + -- - In the rare case that the exception itself stores an 'ExceptionContext',
|
|
| 218 | + -- this context should be preserved by 'toException'.
|
|
| 210 | 219 | toException :: e -> SomeException
|
| 211 | 220 | fromException :: SomeException -> Maybe e
|
| 212 | 221 | |
| ... | ... | @@ -229,13 +238,11 @@ class (Typeable e, Show e) => Exception e where |
| 229 | 238 | -- | @since base-4.8.0.0
|
| 230 | 239 | instance Exception Void
|
| 231 | 240 | |
| 232 | --- | This drops any attached 'ExceptionContext'.
|
|
| 241 | +-- | NB: this instance preserves the attached 'ExceptionContext'.
|
|
| 233 | 242 | --
|
| 234 | 243 | -- @since base-3.0
|
| 235 | 244 | instance Exception SomeException where
|
| 236 | - toException (SomeException e) =
|
|
| 237 | - let ?exceptionContext = emptyExceptionContext
|
|
| 238 | - in SomeException e
|
|
| 245 | + toException = id
|
|
| 239 | 246 | fromException = Just
|
| 240 | 247 | backtraceDesired (SomeException e) = backtraceDesired e
|
| 241 | 248 | displayException (SomeException e) = displayException e
|
| 1 | -<interactive>: Uncaught exception ghc-9.13-inplace:GHC.Utils.Panic.GhcException:
|
|
| 1 | +<interactive>: Uncaught exception ghc-9.12.4.20260710-inplace:GHC.Utils.Panic.GhcException:
|
|
| 2 | 2 | |
| 3 | 3 | IO error: "Abcde" does not exist
|
| 4 | 4 | |
| 5 | 5 | While handling IO error: "Abcde" does not exist
|
| 6 | 6 | |
| 7 | 7 | HasCallStack backtrace:
|
| 8 | - throwIO, called at compiler/GHC/Utils/Error.hs:512:19 in ghc-9.13-inplace:GHC.Utils.Error
|
|
| 8 | + throwIO, called at compiler/GHC/Utils/Error.hs:512:19 in ghc-9.12.4.20260710-inplace:GHC.Utils.Error
|
|
| 9 | 9 | |
| 10 | 10 | 1 |
| ... | ... | @@ -4,3 +4,8 @@ foo |
| 4 | 4 | |
| 5 | 5 | HasCallStack backtrace:
|
| 6 | 6 | error, called at ghc-e005.hs:12:10 in main:Main
|
| 7 | + |
|
| 8 | + |
|
| 9 | +HasCallStack backtrace:
|
|
| 10 | + throwIO, called at ghc\GHCi\UI.hs:1655:31 in ghc-bin-10.1.20260629-inplace:GHCi.UI
|
|
| 11 | + |