Skip to content
  • Simon Peyton Jones's avatar
    Deal with exceptions in dsWhenNoErrs · e7701976
    Simon Peyton Jones authored
    Gracious me.  Ever since this patch
    
      commit 37445780
      Author: Jan Stolarek <jan.stolarek@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.
    e7701976