[GHC] #8639: GHC API `runStmt` overrides qualified import of `it` variable

GHC ghc-devs at haskell.org
Mon Dec 30 17:59:52 UTC 2013


#8639: GHC API `runStmt` overrides qualified import of `it` variable
------------------------------------+-------------------------------------
       Reporter:  agibiansky        |             Owner:
           Type:  bug               |            Status:  new
       Priority:  normal            |         Milestone:
      Component:  GHC API           |           Version:  7.6.3
       Keywords:                    |  Operating System:  Unknown/Multiple
   Architecture:  Unknown/Multiple  |   Type of failure:  None/Unknown
     Difficulty:  Unknown           |         Test Case:
     Blocked By:                    |          Blocking:
Related Tickets:                    |
------------------------------------+-------------------------------------
 The `runStmt` function in `InteractiveEval` creates an `it` variable
 storing the last result. However, this variable somehow shadows qualified
 variables with the name `it`. For instance, importing Test.Hspec, running
 any statement, and then trying to use Test.Hspec.it (qualified) results in
 an "out of scope" error.

 The following small program demonstrates this:

 {{{
 import GHC
 import GhcMonad
 import Outputable
 import GHC.Paths

 main = runGhc (Just libdir) $ do
   flags <- getSessionDynFlags
   setSessionDynFlags (flags{ hscTarget = HscInterpreted, ghcLink =
 LinkInMemory})
   imps <- mapM parseImportDecl ["import Prelude", "import Test.Hspec"]
   setContext (map IIDecl imps)

   -- With the next line, you get an "Not in scope" exception.
   -- If you comment out this runStmt, it runs without error and prints the
 type.
   runStmt "3" RunToCompletion

   exprType "Test.Hspec.it" >>= (liftIO . putStrLn . showPpr flags)
 }}}


 GHCi somehow avoids this, but I have no idea how and could not figure it
 out from the sources.

 What's going on?

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8639>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list