Skip to content

ghci ignores stuff after an import command and a semicolon

I can put a semicolon and then an expression or declaration after an import command in ghci, and the expression or declaration is simply ignored.

rwbarton@morphism:~/ghc$ ghci-7.10.1
GHCi, version 7.10.1: http://www.haskell.org/ghc/  :? for help
Prelude> import Data.List; x
Prelude Data.List>

The stuff after the semicolon does have to parse, but then is discarded. Pretty confusing.

It's especially confusing when using ghc -e

rwbarton@morphism:~/ghc$ ghc-7.10.1 -e "import Data.List; sort [2,1]"
rwbarton@morphism:~/ghc$ echo $?
0

The command is wrong (in general you cannot give multiple commands separated by semicolons, you must use multiple -e options), but GHC fails to complain in any way and silently ignores the "second command".

Trac metadata
Trac field Value
Version 7.10.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component GHCi
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