@@ -47,9 +47,10 @@ import qualified GHC
47
47
import GhcMonad
48
48
import GhcPlugins as GHC hiding (fst3 , (<>) )
49
49
import qualified HeaderInfo as Hdr
50
- import HscMain (hscInteractive )
50
+ import HscMain (hscInteractive , hscSimplify )
51
51
import MkIface
52
52
import StringBuffer as SB
53
+ import TcRnMonad (tcg_th_coreplugins )
53
54
import TidyPgm
54
55
55
56
import Control.Monad.Extra
@@ -148,9 +149,14 @@ compileModule packageState deps tmr =
148
149
let pm' = pm{pm_mod_summary = tweak $ pm_mod_summary pm}
149
150
let tm' = tm{tm_parsed_module = pm'}
150
151
GHC. dm_core_module <$> GHC. desugarModule tm'
151
-
152
+ let tc_result = fst (tm_internals_ (tmrModule tmr))
153
+ -- Have to call the simplifier on the code even if we are at
154
+ -- -O0 as otherwise the code generation fails which leads to
155
+ -- errors like #256
156
+ plugins <- liftIO $ readIORef (tcg_th_coreplugins tc_result)
157
+ desugared_guts <- liftIO $ hscSimplify session plugins desugar
152
158
-- give variables unique OccNames
153
- (guts, details) <- liftIO $ tidyProgram session desugar
159
+ (guts, details) <- liftIO $ tidyProgram session desugared_guts
154
160
return (map snd warnings, (mg_safe_haskell desugar, guts, details))
155
161
156
162
generateByteCode :: HscEnv -> [TcModuleResult ] -> TcModuleResult -> CgGuts -> IO (IdeResult Linkable )
0 commit comments