<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Wonderful, thank you for the investigation! (Well, maybe not so wonderful if it isn’t actually fixed yet, but your followup comment in the issue gives me hope it is.) I’ll take the discussion over there, then.<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Oct 28, 2019, at 05:06, Sebastian Graf <<a href="mailto:sgraf1337@gmail.com" class="">sgraf1337@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">Hi Alexis,</div><div class=""><br class=""></div><div class="">I think the fact that it looks like it's fixed is only a coincidence. See <a href="https://gitlab.haskell.org/ghc/ghc/issues/17409" class="">https://gitlab.haskell.org/ghc/ghc/issues/17409</a>, where I go into a bit more detail.</div><div class=""><br class=""></div><div class="">Cheers<br class=""></div><div class="">Sebastian<br class=""></div></div><br class=""><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Am Mo., 28. Okt. 2019 um 07:16 Uhr schrieb Alexis King <<a href="mailto:lexi.lambda@gmail.com" class="">lexi.lambda@gmail.com</a>>:<br class=""></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi all,<br class="">
<br class="">
I have an odd question: I’ve bumped into a clear simplifier bug, and although it only happens on GHC 8.6.5, not 8.8.1, I’d like to locate the change that fixed it. My library’s test suite currently fails on GHC 8.6.5 due to the bug, and I’d rather not force all my users to upgrade to 8.8 if I can help it, so I’m hoping to find a workaround.<br class="">
<br class="">
The minimal test case I’ve found for the bug is this program:<br class="">
<br class="">
    {-# LANGUAGE GeneralizedNewtypeDeriving, StandaloneDeriving, TypeFamilies #-}<br class="">
<br class="">
    import Control.Exception<br class="">
    import Control.Monad.IO.Class<br class="">
    import Control.Monad.Trans.Identity<br class="">
    import Control.Monad.Trans.Reader<br class="">
<br class="">
    class Monad m => MonadFoo m where<br class="">
      foo :: m a -> m a<br class="">
    instance MonadFoo IO where<br class="">
      foo m = onException m (pure ())<br class="">
    instance MonadFoo m => MonadFoo (ReaderT r m) where<br class="">
      foo m = ReaderT $ \r -> foo (runReaderT m r)<br class="">
    deriving instance MonadFoo m => MonadFoo (IdentityT m)<br class="">
<br class="">
    type family F m where<br class="">
      F m = IdentityT m<br class="">
<br class="">
    newtype FT m a = FT { runFT :: F m a }<br class="">
      deriving (Functor, Applicative, Monad, MonadIO, MonadFoo)<br class="">
<br class="">
    main :: IO ()<br class="">
    main = run (foo (liftIO (throwIO (IndexOutOfBounds "bang"))))<br class="">
      where<br class="">
        run :: ReaderT () (FT (ReaderT () IO)) a -> IO a<br class="">
        run = flip runReaderT () . runIdentityT . runFT . flip runReaderT ()<br class="">
<br class="">
Using GHC 8.6.5 on macOS 10.14.5, compiling this program with optimizations reliably triggers the -fcatch-bottoms sanitization:<br class="">
<br class="">
    $ ghc -O -fcatch-bottoms weird.hs && ./weird<br class="">
    [1 of 1] Compiling Main             ( weird.hs, weird.o )<br class="">
    Linking weird ...<br class="">
    weird: Bottoming expression returned<br class="">
<br class="">
What goes wrong? Somehow the generated core for this program includes the following:<br class="">
<br class="">
    lvl_s47B :: SomeException<br class="">
    lvl_s47B = $fExceptionArrayException_$ctoException lvl_s483<br class="">
<br class="">
    m_s47r :: () -> State# RealWorld -> (# State# RealWorld, () #)<br class="">
    m_s47r<br class="">
      = \ _ (eta_B1 :: State# RealWorld) -> raiseIO# lvl_s47B eta_B1<br class="">
<br class="">
    main_s2Ww :: State# RealWorld -> (# State# RealWorld, () #)<br class="">
    main_s2Ww<br class="">
      = \ (eta_a2wK :: State# RealWorld) -><br class="">
          catch# (case m_s47r `cast` <Co:33> of { }) raiseIO# eta_a2wK<br class="">
<br class="">
This core is completely bogus: it assumes that m_s47r is bottom, but m_s47r is a top-level function! The program still passes -dcore-lint, unfortunately, as it is still well-typed. (Also, in case it helps: -ddump-simplifier-iterations shows that the buggy transformation occurs in the first iteration of the very first simplifier pass.)<br class="">
<br class="">
I’ve been trying to figure out what change might have fixed this so that I can assess if it’s possible to work around, but I haven’t found anything obvious. I’ve been slowly `git bisect`ing to look for the commit that introduced the fix, but many of the commits I’ve tested cause unrelated panics on my machine, which has been exacerbating the problem of the slow recompilation times. I’m a little at wits’ end, but opening a bug report hasn’t felt right, since the bug does appear to already be fixed.<br class="">
<br class="">
Does this issue ring any bells to anyone on this list? Is there a particular patch that landed between GHC 8.6.5 and GHC 8.8.1 that might have fixed this problem? If not, I’ll keep trying with `git bisect`, but I’d appreciate any pointers.<br class="">
<br class="">
Thanks,<br class="">
Alexis<br class="">
<br class="">
_______________________________________________<br class="">
ghc-devs mailing list<br class="">
<a href="mailto:ghc-devs@haskell.org" target="_blank" class="">ghc-devs@haskell.org</a><br class="">
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" rel="noreferrer" target="_blank" class="">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a><br class="">
</blockquote></div>
</div></blockquote></div><br class=""></body></html>