Skip to content

Debugger confuses variables

Consider the following example:

import Control.Exception

f = do
  ma <- try $ evaluate a
  case ma of
    Right str -> return a
    Left  err -> return $ show (err :: SomeException)
  where
    a :: String
    a = error "hi"

Load into ghci, set a breakpoint on the 5th line, then run f:

:break 5
f

You will get

Stopped at Ex.hs:(5,3)-(7,53)
_result :: IO String = _
a :: Either SomeException String = Left _

This doesn't make sense. a has type String; it is ma that has type Either SomeException String.

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