Skip to content

ghci line numbers are off by one

rwbarton@morphism:/tmp$ ghci-7.10.1 
GHCi, version 7.10.1: http://www.haskell.org/ghc/  :? for help
Prelude> 3 : 'a'

<interactive>:2:5:
    Couldn't match expected type ‘[a]’ with actual type ‘Char’
    Relevant bindings include it :: [a] (bound at <interactive>:2:1)
    In the second argument of ‘(:)’, namely ‘'a'’
    In the expression: 3 : 'a'
    In an equation for ‘it’: it = 3 : 'a'
Prelude> 3 : 'a'

<interactive>:3:5:
    Couldn't match expected type ‘[a]’ with actual type ‘Char’
    Relevant bindings include it :: [a] (bound at <interactive>:3:1)
    In the second argument of ‘(:)’, namely ‘'a'’
    In the expression: 3 : 'a'
    In an equation for ‘it’: it = 3 : 'a'
Prelude>

Why are the errors reported as being on lines 2 and 3? And no, I don't buy that line 1 was the GHCi welcome message :)

Apparently it's been like this since at least GHC 7.4 and I've never noticed.

ghc -e cmd1 -e cmd2 reports every command as beginning on a new line 1, which is also weird.

Trac metadata
Trac field Value
Version 7.10.1
Type Bug
TypeOfFailure OtherFailure
Priority low
Resolution Unresolved
Component GHCi
Test case
Differential revisions
BlockedBy
Related
Blocking
CC hvr
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information