From 5afc160dee7142c96a842037fb64bee1429ad9ec Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Sat, 9 May 2020 14:08:25 -0400 Subject: Ensure that printMinimalImports closes handle Fixes #18166. --- compiler/GHC/Rename/Names.hs | 5 ++--- 1 file 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 -- cgit v1.2.1