[commit: ghc] master: Mention "handle is semi-closed" in error messages (9017f16)

git at git.haskell.org git at git.haskell.org
Tue Dec 15 00:37:46 UTC 2015


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/9017f16a78d66fe5aaf0ec98aeb9add1792fd838/ghc

>---------------------------------------------------------------

commit 9017f16a78d66fe5aaf0ec98aeb9add1792fd838
Author: Thomas Miedema <thomasmiedema at gmail.com>
Date:   Tue Dec 15 01:02:39 2015 +0100

    Mention "handle is semi-closed" in error messages
    
    Semi-closedness is mentioned in the Haskell report, so lets not hide it
    from users.
    
    Reviewers: austin, hvr, bgamari
    
    Reviewed By: bgamari
    
    Differential Revision: https://phabricator.haskell.org/D1624


>---------------------------------------------------------------

9017f16a78d66fe5aaf0ec98aeb9add1792fd838
 libraries/base/GHC/IO/Handle.hs           | 10 +++++-----
 libraries/base/GHC/IO/Handle/Internals.hs | 14 +++++++++-----
 libraries/base/tests/IO/IOError001.stdout |  4 ++--
 3 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/libraries/base/GHC/IO/Handle.hs b/libraries/base/GHC/IO/Handle.hs
index 23272ce..ac37ad4 100644
--- a/libraries/base/GHC/IO/Handle.hs
+++ b/libraries/base/GHC/IO/Handle.hs
@@ -113,7 +113,7 @@ hFileSize handle =
     withHandle_ "hFileSize" handle $ \ handle_ at Handle__{haDevice=dev} -> do
     case haType handle_ of
       ClosedHandle              -> ioe_closedHandle
-      SemiClosedHandle          -> ioe_closedHandle
+      SemiClosedHandle          -> ioe_semiclosedHandle
       _ -> do flushWriteBuffer handle_
               r <- IODevice.getSize dev
               if r /= -1
@@ -129,7 +129,7 @@ hSetFileSize handle size =
     withHandle_ "hSetFileSize" handle $ \ handle_ at Handle__{haDevice=dev} -> do
     case haType handle_ of
       ClosedHandle              -> ioe_closedHandle
-      SemiClosedHandle          -> ioe_closedHandle
+      SemiClosedHandle          -> ioe_semiclosedHandle
       _ -> do flushWriteBuffer handle_
               IODevice.setSize dev size
               return ()
@@ -473,7 +473,7 @@ hIsReadable handle =
     withHandle_ "hIsReadable" handle $ \ handle_ -> do
     case haType handle_ of
       ClosedHandle         -> ioe_closedHandle
-      SemiClosedHandle     -> ioe_closedHandle
+      SemiClosedHandle     -> ioe_semiclosedHandle
       htype                -> return (isReadableHandleType htype)
 
 hIsWritable :: Handle -> IO Bool
@@ -482,7 +482,7 @@ hIsWritable handle =
     withHandle_ "hIsWritable" handle $ \ handle_ -> do
     case haType handle_ of
       ClosedHandle         -> ioe_closedHandle
-      SemiClosedHandle     -> ioe_closedHandle
+      SemiClosedHandle     -> ioe_semiclosedHandle
       htype                -> return (isWritableHandleType htype)
 
 -- | Computation 'hGetBuffering' @hdl@ returns the current buffering mode
@@ -503,7 +503,7 @@ hIsSeekable handle =
     withHandle_ "hIsSeekable" handle $ \ handle_ at Handle__{..} -> do
     case haType of
       ClosedHandle         -> ioe_closedHandle
-      SemiClosedHandle     -> ioe_closedHandle
+      SemiClosedHandle     -> ioe_semiclosedHandle
       AppendHandle         -> return False
       _                    -> IODevice.isSeekable haDevice
 
diff --git a/libraries/base/GHC/IO/Handle/Internals.hs b/libraries/base/GHC/IO/Handle/Internals.hs
index 99cfb31..37251ab 100644
--- a/libraries/base/GHC/IO/Handle/Internals.hs
+++ b/libraries/base/GHC/IO/Handle/Internals.hs
@@ -42,7 +42,8 @@ module GHC.IO.Handle.Internals (
   decodeByteBuf,
 
   augmentIOError,
-  ioe_closedHandle, ioe_EOF, ioe_notReadable, ioe_notWritable,
+  ioe_closedHandle, ioe_semiclosedHandle,
+  ioe_EOF, ioe_notReadable, ioe_notWritable,
   ioe_finalizedHandle, ioe_bufsiz,
 
   hClose_help, hLookAhead_,
@@ -238,7 +239,7 @@ checkWritableHandle :: (Handle__ -> IO a) -> Handle__ -> IO a
 checkWritableHandle act h_ at Handle__{..}
   = case haType of
       ClosedHandle         -> ioe_closedHandle
-      SemiClosedHandle     -> ioe_closedHandle
+      SemiClosedHandle     -> ioe_semiclosedHandle
       ReadHandle           -> ioe_notWritable
       ReadWriteHandle      -> do
         buf <- readIORef haCharBuffer
@@ -277,7 +278,7 @@ checkReadableHandle :: (Handle__ -> IO a) -> Handle__ -> IO a
 checkReadableHandle act h_ at Handle__{..} =
     case haType of
       ClosedHandle         -> ioe_closedHandle
-      SemiClosedHandle     -> ioe_closedHandle
+      SemiClosedHandle     -> ioe_semiclosedHandle
       AppendHandle         -> ioe_notReadable
       WriteHandle          -> ioe_notReadable
       ReadWriteHandle      -> do
@@ -307,7 +308,7 @@ checkSeekableHandle :: (Handle__ -> IO a) -> Handle__ -> IO a
 checkSeekableHandle act handle_ at Handle__{haDevice=dev} =
     case haType handle_ of
       ClosedHandle      -> ioe_closedHandle
-      SemiClosedHandle  -> ioe_closedHandle
+      SemiClosedHandle  -> ioe_semiclosedHandle
       AppendHandle      -> ioe_notSeekable
       _ -> do b <- IODevice.isSeekable dev
               if b then act handle_
@@ -316,13 +317,16 @@ checkSeekableHandle act handle_ at Handle__{haDevice=dev} =
 -- -----------------------------------------------------------------------------
 -- Handy IOErrors
 
-ioe_closedHandle, ioe_EOF,
+ioe_closedHandle, ioe_semiclosedHandle, ioe_EOF,
   ioe_notReadable, ioe_notWritable, ioe_cannotFlushNotSeekable,
   ioe_notSeekable :: IO a
 
 ioe_closedHandle = ioException
    (IOError Nothing IllegalOperation ""
         "handle is closed" Nothing Nothing)
+ioe_semiclosedHandle = ioException
+   (IOError Nothing IllegalOperation ""
+        "handle is semi-closed" Nothing Nothing)
 ioe_EOF = ioException
    (IOError Nothing EOF "" "" Nothing Nothing)
 ioe_notReadable = ioException
diff --git a/libraries/base/tests/IO/IOError001.stdout b/libraries/base/tests/IO/IOError001.stdout
index 1e689bb..c235b62 100644
--- a/libraries/base/tests/IO/IOError001.stdout
+++ b/libraries/base/tests/IO/IOError001.stdout
@@ -1,2 +1,2 @@
-<stdin>: hGetChar: illegal operation (handle is closed)
-<stdin>: hGetChar: illegal operation (handle is closed)
+<stdin>: hGetChar: illegal operation (handle is semi-closed)
+<stdin>: hGetChar: illegal operation (handle is semi-closed)



More information about the ghc-commits mailing list