summaryrefslogtreecommitdiff
path: root/testsuite/tests/ghc-api/T8639_api.hs
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2014-01-02 15:18:10 +0000
committerSimon Peyton Jones <simonpj@microsoft.com>2014-01-02 15:18:58 +0000
commit40db99a7c485aa58f9fc3a209fced8720cf5c3e5 (patch)
tree5a19163e3253219d3b6bf62ec1a9c15a85aa444e /testsuite/tests/ghc-api/T8639_api.hs
parentf54fc09bb17226c71deb766306cb2e293c33dc83 (diff)
downloadhaskell-40db99a7c485aa58f9fc3a209fced8720cf5c3e5.tar.gz
Test Trac #8639
Diffstat (limited to 'testsuite/tests/ghc-api/T8639_api.hs')
-rw-r--r--testsuite/tests/ghc-api/T8639_api.hs26
1 files changed, 26 insertions, 0 deletions
diff --git a/testsuite/tests/ghc-api/T8639_api.hs b/testsuite/tests/ghc-api/T8639_api.hs
new file mode 100644
index 0000000000..4232aa00b9
--- /dev/null
+++ b/testsuite/tests/ghc-api/T8639_api.hs
@@ -0,0 +1,26 @@
+module Main where
+
+import GHC
+import GhcMonad
+import Outputable
+import System.IO
+import System.Environment( getArgs )
+
+main
+ = do { [libdir] <- getArgs
+ ; runGhc (Just libdir) $ do
+ flags <- getSessionDynFlags
+ setSessionDynFlags (flags{ hscTarget = HscInterpreted, ghcLink = LinkInMemory})
+ target <- guessTarget "T8639_api_a.hs" Nothing
+ setTargets [target]
+ load LoadAllTargets
+ imps <- mapM parseImportDecl ["import Prelude", "import T8639_api_a"]
+ 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 "putStrLn (show 3)" RunToCompletion
+
+ ty <- exprType "T8639_api_a.it"
+ liftIO (putStrLn (showPpr flags ty))
+ ; hFlush stdout }