From 8c5cce50709d6c0e41aed13df808a36ce13df4a4 Mon Sep 17 00:00:00 2001 From: Lennart Spitzner Date: Mon, 20 Aug 2018 21:19:10 +0200 Subject: [PATCH] Prevent package environment file GHC API stupidities This fixes the code-path for the commandline interface (unfortunately not covered by our testsuite). The other code-path should be covered by the changes in https://github.com/alanz/ghc-exactprint/pull/68. --- .../Haskell/Brittany/Internal/ExactPrintUtils.hs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Language/Haskell/Brittany/Internal/ExactPrintUtils.hs b/src/Language/Haskell/Brittany/Internal/ExactPrintUtils.hs index 375c779..7c582f1 100644 --- a/src/Language/Haskell/Brittany/Internal/ExactPrintUtils.hs +++ b/src/Language/Haskell/Brittany/Internal/ExactPrintUtils.hs @@ -70,8 +70,14 @@ parseModuleWithCpp parseModuleWithCpp cpp opts args fp dynCheck = ExactPrint.ghcWrapper $ ExceptT.runExceptT $ do dflags0 <- lift $ GHC.getSessionDynFlags - (dflags1, leftover, warnings) <- lift - $ GHC.parseDynamicFlagsCmdLine dflags0 (GHC.noLoc <$> args) + (dflags1, leftover, warnings) <- lift $ GHC.parseDynamicFlagsCmdLine + dflags0 + (GHC.noLoc <$> ("-hide-all-packages" : args)) + -- that we pass -hide-all-packages here is a duplication, because + -- ExactPrint.initDynFlags also does it, but necessary because of + -- stupid and careless GHC API design. We explicitly want to pass + -- our args before calling that, so this is what we do. Should be + -- harmless. See commit 1b7576dcd1823e1c685a44927b1fcaade1319063. void $ lift $ GHC.setSessionDynFlags dflags1 dflags2 <- lift $ ExactPrint.initDynFlags fp when (not $ null leftover)