diff options
author | Ben Gamari <ben@smart-cactus.org> | 2020-05-09 14:08:25 -0400 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-05-13 20:09:07 -0400 |
commit | 1c999e5d4e63e7b407b174f51913cfa38e2dec46 (patch) | |
tree | c313e564f24462a8f377e3573b74f0dc629a5057 | |
parent | 404581eaa3bf8d3f100da7610a6a38158bea17c4 (diff) | |
download | haskell-1c999e5d4e63e7b407b174f51913cfa38e2dec46.tar.gz |
Ensure that printMinimalImports closes handle
Fixes #18166.
-rw-r--r-- | compiler/GHC/Rename/Names.hs | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/compiler/GHC/Rename/Names.hs b/compiler/GHC/Rename/Names.hs index db74847707..9e7f1a4216 100644 --- a/compiler/GHC/Rename/Names.hs +++ b/compiler/GHC/Rename/Names.hs @@ -1619,9 +1619,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 |