[commit: ghc] master: Deal with exceptions in dsWhenNoErrs (e770197)

git at git.haskell.org git at git.haskell.org
Thu May 4 16:27:31 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/e77019767fe5327011c6dc8fe089c64884120aab/ghc

>---------------------------------------------------------------

commit e77019767fe5327011c6dc8fe089c64884120aab
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Thu May 4 13:33:04 2017 +0100

    Deal with exceptions in dsWhenNoErrs
    
    Gracious me.  Ever since this patch
    
      commit 374457809de343f409fbeea0a885877947a133a2
      Author: Jan Stolarek <jan.stolarek at p.lodz.pl>
      Date:   Fri Jul 11 13:54:45 2014 +0200
    
          Injective type families
    
    TcRnMonad.askNoErrs has been wrong. It looked like this
    
       askNoErrs :: TcRn a -> TcRn (a, Bool)
       askNoErrs m
        = do { errs_var <- newTcRef emptyMessages
             ; res  <- setErrsVar errs_var m
             ; (warns, errs) <- readTcRef errs_var
             ; addMessages (warns, errs)
             ; return (res, isEmptyBag errs) }
    
    The trouble comes if 'm' throws an exception in the TcRn monad.
    Then 'errs_var is never read, so any errors are simply lost.
    
    This mistake was then propgated into DsMonad.dsWhenNoErrs, where
    it gave rise to Trac #13642.
    
    Thank to Ryan for narrowing it down so sharply.
    
    I did some refactoring, as usual.


>---------------------------------------------------------------

e77019767fe5327011c6dc8fe089c64884120aab
 compiler/deSugar/DsMonad.hs       |  32 +++++++++---
 compiler/ghci/RtClosureInspect.hs |  10 ++--
 compiler/typecheck/TcRnDriver.hs  |   2 +-
 compiler/typecheck/TcRnMonad.hs   | 102 +++++++++++++++++++-------------------
 compiler/typecheck/TcSplice.hs    |   8 +--
 testsuite/tests/th/T13642.hs      |   9 ++++
 testsuite/tests/th/T13642.stderr  |   4 ++
 testsuite/tests/th/all.T          |   1 +
 8 files changed, 94 insertions(+), 74 deletions(-)

Diff suppressed because of size. To see it, use:

    git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc e77019767fe5327011c6dc8fe089c64884120aab


More information about the ghc-commits mailing list