Changes between Initial Version and Version 2 of Ticket #9236


Ignore:
Timestamp:
Jun 24, 2014 6:39:05 PM (9 months ago)
Author:
dfeuer
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #9236

    • Property Difficulty changed from Unknown to Easy (less than 1 hour)
    • Property Cc hvr ekmett added
    • Property Component changed from Compiler to libraries/base
    • Property Type of failure changed from None/Unknown to Other
    • Property Version changed from 7.6.3 to 7.8.2
  • Ticket #9236 – Description

    initial v2  
    55}}} 
    66 
    7 The problem, of course, is that the result of `withFile "file" ReadMode hGetContents` isn't forced until `putStr` is executed, at which point the file has already been closed. The Haskell report doesn't specify what it will find, and, at least in 7.6.3, it finds the string empty. The behavior that seems most correct to me would be to guarantee that if a file has not been completely read (or read up to an I/O error) when it is closed, then its contents should be reported as something like `"Four score and seven years ag"++error "Forcing a suspended computation led to an attempted read from a handle that was already closed."` Since the current system apparently puts an `[]` as a temporary marker while waiting to see what the rest of the list will be, I imagine that the fix is as simple as putting the error thunk there instead. 
     7The problem, of course, is that the result of `withFile "file" ReadMode hGetContents` isn't forced until `putStr` is executed, at which point the file has already been closed. The Haskell report doesn't specify what it will find, and, at least in 7.6.3, it finds the string empty. The behavior that seems most correct to me would be to guarantee that if a file has not been completely read (or read up to an I/O error) when it is closed, then its contents should be reported as something like `"Four score and seven years ag"++error "Forcing a suspended computation led to an attempted read from a handle that was already closed."` My suggested fix is in a comment below.