on master help sign in
Pass correct SafeHaskell information to mkIfaceTc (#489)

Seems like this was never implemented the first time, woops! Fixes #424

commit7ecdd21874e1b9c638502c47d61facd3be581c65 authorMatthew Pickering <matthewtpickering@gmail.com> dateThu 19 Mar 2020, 12:49 (7 years ago) parent8ba58cc
2 files changed+34−2
src/Development/IDE/Core/Compile.hs+3−2 test/exe/Main.hs+31
src/Development/IDE/Core/Compile.hs+3−2
@@ -234,10 +234,11 @@ mkTcModuleResult
234234 -> m TcModuleResult
235235mkTcModuleResult tcm = do
236236 session <- getSession
237+ let sf = modInfoSafe (tm_checked_module_info tcm)
237238#if MIN_GHC_API_VERSION(8,10,0)
238− iface <- liftIO $ mkIfaceTc session Sf_None details tcGblEnv
239+ iface <- liftIO $ mkIfaceTc session sf details tcGblEnv
239240#else
240− (iface, _) <- liftIO $ mkIfaceTc session Nothing Sf_None details tcGblEnv
241+ (iface, _) <- liftIO $ mkIfaceTc session Nothing sf details tcGblEnv
241242#endif
242243 let mod_info = HomeModInfo iface details Nothing
243244 return $ TcModuleResult tcm mod_info
test/exe/Main.hs+31
@@ -63,6 +63,7 @@ main = defaultMainWithRerun $ testGroup "HIE"
6363 , pluginTests
6464 , preprocessorTests
6565 , thTests
66+ , safeTests
6667 , unitTests
6768 , haddockTests
6869 , positionMappingTests
@@ -1485,6 +1486,36 @@ preprocessorTests = testSessionWait "preprocessor" $ do
14851486 )
14861487 ]
14871488
1489+
1490+safeTests :: TestTree
1491+safeTests =
1492+ testGroup
1493+ "SafeHaskell"
1494+ [ -- Test for https://github.com/digital-asset/ghcide/issues/424
1495+ testSessionWait "load" $ do
1496+ let sourceA =
1497+ T.unlines
1498+ ["{-# LANGUAGE Trustworthy #-}"
1499+ ,"module A where"
1500+ ,"import System.IO.Unsafe"
1501+ ,"import System.IO"
1502+ ,"trustWorthyId :: a -> a"
1503+ ,"trustWorthyId i = unsafePerformIO $ do"
1504+ ," putStrLn \"I'm safe\""
1505+ ," return i"]
1506+ sourceB =
1507+ T.unlines
1508+ ["{-# LANGUAGE Safe #-}"
1509+ ,"module B where"
1510+ ,"import A"
1511+ ,"safeId :: a -> a"
1512+ ,"safeId = trustWorthyId"
1513+ ]
1514+
1515+ _ <- openDoc' "A.hs" "haskell" sourceA
1516+ _ <- openDoc' "B.hs" "haskell" sourceB
1517+ expectNoMoreDiagnostics 1 ]
1518+
14881519thTests :: TestTree
14891520thTests =
14901521 testGroup