summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2020-05-09 14:08:25 -0400
committerBen Gamari <ben@smart-cactus.org>2020-05-09 14:08:25 -0400
commit5afc160dee7142c96a842037fb64bee1429ad9ec (patch)
tree7797dc46e0ace03601fa371c45be3abfc61c650b
parent86c77b36628dcce7bc9b066fc24c8c521fecc3ee (diff)
downloadhaskell-wip/T18166.tar.gz
Ensure that printMinimalImports closes handlewip/T18166
Fixes #18166.
-rw-r--r--compiler/GHC/Rename/Names.hs5
1 files changed, 2 insertions, 3 deletions
diff --git a/compiler/GHC/Rename/Names.hs b/compiler/GHC/Rename/Names.hs
index cd39ed701d..f916df7836 100644
--- a/compiler/GHC/Rename/Names.hs
+++ b/compiler/GHC/Rename/Names.hs
@@ -1612,9 +1612,8 @@ printMinimalImports imports_w_usage
= do { imports' <- getMinimalImports imports_w_usage
; this_mod <- getModule
; dflags <- getDynFlags
- ; liftIO $
- do { h <- openFile (mkFilename dflags this_mod) WriteMode
- ; printForUser dflags h neverQualify (vcat (map ppr imports')) }
+ ; liftIO $ withFile (mkFilename dflags this_mod) WriteMode $ \h ->
+ printForUser dflags h neverQualify (vcat (map ppr imports'))
-- The neverQualify is important. We are printing Names
-- but they are in the context of an 'import' decl, and
-- we never qualify things inside there