Skip to content

GHCi stdin buffering strange

Ben Rudiak-Gould reports

This is a bizarre problem that's been randomly biting me 
for ages, but I 
just recently figured out how to reliably reproduce it.

Steps to reproduce:

    1. Install GHC 6.2.2 for Win32 from the MSI file at 
haskell.org. 
(Older versions also exhibit the bug.)
    2. Start GHCi from the command line with no options. 
While it's 
loading (before the Prelude> prompt appears), press the 
letter 'p' on 
the keyboard.
    3. After the prompt appears, press the 'i' and Enter 
keys.
    4. Instead of "3.141592653589793", GHCi 
reports "Variable not in 
scope: `gi'".

The character that gets munged is always the first 
character of the 
input line, and it always gets replaced with the letter g, 
regardless of 
what it was initially. It's not visibly munged: that is, the 
interaction 
looks like

    Prelude> pi

    <interactive>:1: Variable not in scope: `gi'

The same problem appears if I press both 'p' and 'i' 
before the prompt 
appears, and Enter after. But it does not appear if I 
press all three 
keys before the prompt appears, or all three after. (I 
told you it was 
weird.)

I seem to remember that using :r or :l also triggers the 
bug on the next 
input, but I haven't tested that recently.

I've encountered this problem on at least two different 
machines, at 
least two versions of NT (Win2K and WinXP), and many 
versions of GHC.
Trac metadata
Trac field Value
Version None
Type Bug
TypeOfFailure OtherFailure
Priority lowest
Resolution ResolvedDuplicate
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information