diff options
author | Reid Barton <rwbarton@gmail.com> | 2014-12-23 16:16:29 -0500 |
---|---|---|
committer | Reid Barton <rwbarton@gmail.com> | 2014-12-23 16:16:29 -0500 |
commit | cc510b46b4f6046115cd74acc2c8726c91823bcf (patch) | |
tree | b52fb8532fde8d9b69f9251ffb4a090e58590856 /ghc | |
parent | 878910e1c4520732ab9d8372c1c81f00d484e48f (diff) | |
download | haskell-cc510b46b4f6046115cd74acc2c8726c91823bcf.tar.gz |
Make ghc -e fail on invalid declarations
Summary:
Note: This commit includes an API change to GhciMonad.runDecls
to allow the caller to determine whether the declarations were
run successfully or not.
Test Plan: harbormaster
Reviewers: austin
Reviewed By: austin
Subscribers: carter, thomie
Differential Revision: https://phabricator.haskell.org/D582
Diffstat (limited to 'ghc')
-rw-r--r-- | ghc/GhciMonad.hs | 8 | ||||
-rw-r--r-- | ghc/InteractiveUI.hs | 6 |
2 files changed, 9 insertions, 5 deletions
diff --git a/ghc/GhciMonad.hs b/ghc/GhciMonad.hs index f57fbba101..19b900995a 100644 --- a/ghc/GhciMonad.hs +++ b/ghc/GhciMonad.hs @@ -277,15 +277,17 @@ runStmt expr step = do r <- GHC.runStmtWithLocation (progname st) (line_number st) expr step return (Just r) -runDecls :: String -> GHCi [GHC.Name] +runDecls :: String -> GHCi (Maybe [GHC.Name]) runDecls decls = do st <- getGHCiState reifyGHCi $ \x -> withProgName (progname st) $ withArgs (args st) $ reflectGHCi x $ do - GHC.handleSourceError (\e -> do GHC.printException e; return []) $ do - GHC.runDeclsWithLocation (progname st) (line_number st) decls + GHC.handleSourceError (\e -> do GHC.printException e; + return Nothing) $ do + r <- GHC.runDeclsWithLocation (progname st) (line_number st) decls + return (Just r) resume :: (SrcSpan -> Bool) -> GHC.SingleStep -> GHCi GHC.RunResult resume canLogSpan step = do diff --git a/ghc/InteractiveUI.hs b/ghc/InteractiveUI.hs index ce73c48ce5..7125f6d9b3 100644 --- a/ghc/InteractiveUI.hs +++ b/ghc/InteractiveUI.hs @@ -915,8 +915,10 @@ runStmt stmt step where run_decl = do _ <- liftIO $ tryIO $ hFlushAll stdin - result <- GhciMonad.runDecls stmt - afterRunStmt (const True) (GHC.RunOk result) + m_result <- GhciMonad.runDecls stmt + case m_result of + Nothing -> return False + Just result -> afterRunStmt (const True) (GHC.RunOk result) run_stmt = do -- In the new IO library, read handles buffer data even if the Handle |