diff options
author | Ömer Sinan Ağacan <omeragacan@gmail.com> | 2015-07-17 00:06:28 +0200 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2015-07-17 00:08:10 +0200 |
commit | a5e9da8feb5110ab8ee8fe3821e6b6d53946f983 (patch) | |
tree | ec6959c47ef3eb67bec380b09a9e661c51e82f79 /ghc/InteractiveUI.hs | |
parent | 2c9de9c9a3df8e855c883139b0cb2fd41801bd67 (diff) | |
download | haskell-a5e9da8feb5110ab8ee8fe3821e6b6d53946f983.tar.gz |
Fix off-by-one error in GHCi line reporting (Trac #10578)
Test Plan: I couldn't add tests because apparently line number
reporting was already working correctly when loading script files. I
don't know how to test by running commands using stdin, is this
supported?
Reviewers: austin, thomie, bgamari
Reviewed By: thomie, bgamari
Subscribers: hvr, thomie
Differential Revision: https://phabricator.haskell.org/D1067
Diffstat (limited to 'ghc/InteractiveUI.hs')
-rw-r--r-- | ghc/InteractiveUI.hs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/ghc/InteractiveUI.hs b/ghc/InteractiveUI.hs index cd58fc2fff..d834523cff 100644 --- a/ghc/InteractiveUI.hs +++ b/ghc/InteractiveUI.hs @@ -424,7 +424,10 @@ interactiveUI config srcs maybe_exprs = do stop = default_stop, editor = default_editor, options = [], - line_number = 1, + -- We initialize line number as 0, not 1, because we use + -- current line number while reporting errors which is + -- incremented after reading a line. + line_number = 0, break_ctr = 0, breaks = [], tickarrays = emptyModuleEnv, @@ -536,7 +539,7 @@ runGHCi paths maybe_exprs = do let show_prompt = verbosity dflags > 0 || is_tty -- reset line number - modifyGHCiState $ \st -> st{line_number=1} + modifyGHCiState $ \st -> st{line_number=0} case maybe_exprs of Nothing -> @@ -745,7 +748,7 @@ runCommands' eh sourceErrorHandler gCmd = gmask $ \unmask -> do case b of Nothing -> return Nothing Just success -> do - when (not success) $ maybe (return ()) lift sourceErrorHandler + unless success $ maybe (return ()) lift sourceErrorHandler unmask $ runCommands' eh sourceErrorHandler gCmd -- | Evaluate a single line of user input (either :<command> or Haskell code). |