sheaf pushed to branch wip/T27455 at Glasgow Haskell Compiler / GHC

Commits:

4 changed files:

Changes:

  • changelog.d/T27455
    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
    +

  • libraries/base/changelog.md
    ... ... @@ -33,6 +33,7 @@
    33 33
       * Evaluate backtraces for "error" exceptions at the moment they are thrown. ([CLC proposal #383](https://github.com/haskell/core-libraries-committee/issues/383))
    
    34 34
       * Hide implementation details when throwing exceptions in throw and throwSTM. ([CLC proposal #387](https://github.com/haskell/core-libraries-committee/issues/387))
    
    35 35
       * Change `hIsReadable` and `hIsWritable` such that they always throw a respective exception when encountering a closed or semi-closed handle, not just in the case of a file handle. ([CLC proposal #371](github.com/haskell/core-libraries-committee/issues/371))
    
    36
    +  * 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).
    
    36 37
       * Annotate `onException` continuation with `WhileHandling`. ([CLC Proposal #397](https://github.com/haskell/core-libraries-committee/issues/397))
    
    37 38
       * Improve error message for `Data.Char.chr`. ([CLC Proposal #384](https://github.com/haskell/core-libraries-committee/issues/384))
    
    38 39
     
    

  • libraries/ghc-internal/src/GHC/Internal/Exception/Type.hs
    ... ... @@ -55,7 +55,7 @@ import GHC.Internal.Data.Maybe
    55 55
     import GHC.Internal.Data.Typeable (Typeable, TypeRep, cast)
    
    56 56
     import qualified GHC.Internal.Data.Typeable as Typeable
    
    57 57
        -- loop: GHC.Internal.Data.Typeable -> GHC.Internal.Err -> GHC.Internal.Exception
    
    58
    -import GHC.Internal.Base (String, Void, fmap, return, ($), (.), (++))
    
    58
    +import GHC.Internal.Base (String, Void, fmap, return, ($), (.), (++), id)
    
    59 59
     import GHC.Internal.Show
    
    60 60
     import GHC.Internal.Types (Bool(..))
    
    61 61
     import GHC.Internal.Exception.Context
    
    ... ... @@ -231,13 +231,11 @@ class (Typeable e, Show e) => Exception e where
    231 231
     -- | @since base-4.8.0.0
    
    232 232
     instance Exception Void
    
    233 233
     
    
    234
    --- | This drops any attached 'ExceptionContext'.
    
    234
    +-- | NB: this instance preserves the attached 'ExceptionContext'.
    
    235 235
     --
    
    236 236
     -- @since base-3.0
    
    237 237
     instance Exception SomeException where
    
    238
    -    toException (SomeException e) =
    
    239
    -        let ?exceptionContext = emptyExceptionContext
    
    240
    -        in SomeException e
    
    238
    +    toException = id
    
    241 239
         fromException = Just
    
    242 240
         backtraceDesired (SomeException e) = backtraceDesired e
    
    243 241
         displayException (SomeException e) = displayException e
    

  • testsuite/tests/ghc-e/should_run/ghc-e005.stderr
    ... ... @@ -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
    +