[Git][ghc/ghc][wip/romes/exceptions-propagate] 7 commits: exceptions: Improve the message layout as per #285

Rodrigo Mesquita (@alt-romes) gitlab at gitlab.haskell.org
Thu Oct 17 11:15:22 UTC 2024



Rodrigo Mesquita pushed to branch wip/romes/exceptions-propagate at Glasgow Haskell Compiler / GHC


Commits:
dff0d559 by Rodrigo Mesquita at 2024-10-17T12:14:30+01:00
exceptions: Improve the message layout as per #285

This commit fixes the layout of the additional information included when
displaying an exception, namely the type of the exception.

It also fixes the default handler's heading message to work well
together with the improved display message of SomeException.

CLC proposal#285

- - - - -
1207736e by Rodrigo Mesquita at 2024-10-17T12:14:30+01:00
Display type and callstack of exception on handler

This commit changes the Exception instance of SomeException to *simply*
display the underlying exception in `displayException`. The augmented
exception message that included the type and backtrace of the exception
are now only printed on a call to `displayExceptionWithInfo`.

At a surface level, existing programs should behave the same since the
`uncaughtExceptionHandler`, which is responsible for printing out uncaught
exceptions to the user, will use `displayExceptionWithInfo` by default.

However, unlike the instance's `displayException` method, the
`uncaughtExceptionHandler` can be overriden with
`setUncaughtExceptionHandler`. This makes the extra information opt-in
without fixing it the instance, which can be valuable if your program
wants to display uncaught exceptions to users in a user-facing way
(ie without backtraces).

This is what was originally agreed for CLC#231 or CLC#261 with regard to
the type of the exception information.

The call stack also becoming part of the default handler rather than the
Exception instance is an ammendment to CLC#164.

Discussion of the ammendment is part of CLC#285.

- - - - -
99bfaf19 by Rodrigo Mesquita at 2024-10-17T12:14:30+01:00
Remove redundant CallStack from exceptions

Before the exception backtraces proposal was implemented, ErrorCall
accumulated its own callstack via HasCallStack constraints, but
ExceptionContext is now accumulated automatically.

The original ErrorCall mechanism is now redundant and we get a duplicate
CallStack

Updates Cabal submodule to fix their usage of ErrorCallWithLocation to ErrorCall

CLC proposal#285

Fixes #25283

- - - - -
9866ca04 by Rodrigo Mesquita at 2024-10-17T12:14:30+01:00
Freeze call stack in error throwing functions

CLC proposal#285

- - - - -
3d3657f7 by Rodrigo Mesquita at 2024-10-17T12:14:30+01:00
De-duplicate displayContext and displayExceptionContext

The former was unused except for one module where it was essentially
re-defining displayExceptionContext.

Moreover, this commit extends the fix from
bfe600f5bb3ecd2c8fa71c536c63d3c46984e3f8 to displayExceptionContext too,
which was missing.

- - - - -
518aef2b by Rodrigo Mesquita at 2024-10-17T12:14:31+01:00
Re-export NoBacktrace from Control.Exception

This was originally proposed and accepted in section
    "2.7   Capturing Backtraces on Exceptions"
of the CLC proposal for exception backtraces.

However, the implementation missed this re-export, which this commit now
fixes.

- - - - -
27a20764 by Rodrigo Mesquita at 2024-10-17T12:14:31+01:00
Fix exception backtraces from GHCi

When running the program with `runhaskell`/`runghc` the backtrace should
match the backtrace one would get by compiling and running the program.
But currently, an exception thrown in a program interpreted with
`runhaskell` will:

    * Not include the original exception backtrace at all
    * Include the backtrace from the internal GHCi/ghc rethrowing of the
      original exception

This commit fixes this divergence by not annotating the ghc(i) backtrace
(with NoBacktrace) and making sure that the backtrace of the original
exception is serialized across the boundary and rethrown with the
appropriate context.

Fixes #25116

The !13301 MR (not this commit in particular) improves performance of
MultiLayerModulesRecomp:

-------------------------
Metric Decrease:
    MultiLayerModulesRecomp
-------------------------

- - - - -


30 changed files:

- compiler/GHC/Utils/Panic/Plain.hs
- ghc/GHCi/UI/Monad.hs
- libraries/base/src/Control/Exception.hs
- libraries/base/src/GHC/Exception.hs
- libraries/base/tests/IO/T21336/T21336a.stderr
- libraries/base/tests/IO/T21336/T21336b.stderr
- libraries/base/tests/IO/T4808.stderr
- libraries/base/tests/IO/mkdirExists.stderr
- libraries/base/tests/IO/openFile002.stderr
- libraries/base/tests/IO/openFile002.stderr-mingw32
- libraries/base/tests/IO/withBinaryFile001.stderr
- libraries/base/tests/IO/withBinaryFile002.stderr
- libraries/base/tests/IO/withFile001.stderr
- libraries/base/tests/IO/withFile002.stderr
- libraries/base/tests/IO/withFileBlocking001.stderr
- libraries/base/tests/IO/withFileBlocking002.stderr
- libraries/base/tests/T15349.stderr
- libraries/base/tests/T16111.stderr
- libraries/base/tests/T19288.stderr
- libraries/base/tests/T24807.stderr
- libraries/base/tests/all.T
- libraries/base/tests/assert.stderr
- libraries/base/tests/readFloat.stderr
- − libraries/base/tests/topHandler04.hs
- − libraries/base/tests/topHandler04.stderr
- libraries/ghc-compact/tests/compact_function.stderr
- libraries/ghc-compact/tests/compact_mutable.stderr
- libraries/ghc-compact/tests/compact_pinned.stderr
- libraries/ghc-internal/src/GHC/Internal/Conc/Sync.hs
- libraries/ghc-internal/src/GHC/Internal/Exception.hs


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/68b4fe075d2847f1ef7b49cd51a4cdcaff77c31a...27a207643d6aa19aa526be75cb1935ff310690b0

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/68b4fe075d2847f1ef7b49cd51a4cdcaff77c31a...27a207643d6aa19aa526be75cb1935ff310690b0
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/20241017/9d34a735/attachment.html>


More information about the ghc-commits mailing list