Fix thunk leak in CoreM's CoreWriter
authorAndrew Farmer <anfarmer@ku.edu>
Fri, 8 Mar 2013 00:13:03 +0000 (18:13 -0600)
committerIan Lynagh <ian@well-typed.com>
Tue, 4 Jun 2013 19:52:49 +0000 (20:52 +0100)
compiler/simplCore/CoreMonad.lhs

index 3afb8cd..e11c139 100644 (file)
@@ -762,7 +762,8 @@ instance Monad CoreM where
     mx >>= f = CoreM $ \s -> do
             (x, s', w1) <- unCoreM mx s
             (y, s'', w2) <- unCoreM (f x) s'
-            return (y, s'', w1 `plusWriter` w2)
+            let w = w1 `plusWriter` w2 -- forcing w before returning avoids a space leak (Trac #7702)
+            return $ seq w (y, s'', w)
 
 instance Applicative CoreM where
     pure = return