[Git][ghc/ghc][master] Only exit ghci in -e mode when :add command fails

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Wed Dec 6 21:14:13 UTC 2023



Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
d5610737 by Claudio Bley at 2023-12-06T16:13:33-05:00
Only exit ghci in -e mode when :add command fails

Previously, when running `ghci -e ':add Sample.hs'` the process would
exit with exit code 1 if the file exists and could be loaded.

Fixes #24115

- - - - -


4 changed files:

- ghc/GHCi/UI.hs
- + testsuite/tests/ghci/should_run/T24115.hs
- + testsuite/tests/ghci/should_run/T24115.script
- testsuite/tests/ghci/should_run/all.T


Changes:

=====================================
ghc/GHCi/UI.hs
=====================================
@@ -2098,8 +2098,9 @@ addModule files = do
     checkTargetFile :: GhciMonad m => String -> m Bool
     checkTargetFile f = do
       exists <- liftIO (doesFileExist f)
-      unless exists $ liftIO $ hPutStrLn stderr $ "File " ++ f ++ " not found"
-      failIfExprEvalMode
+      unless exists $ do
+        liftIO $ hPutStrLn stderr $ "File " ++ f ++ " not found"
+        failIfExprEvalMode
       return exists
 
 -- | @:unadd@ command


=====================================
testsuite/tests/ghci/should_run/T24115.hs
=====================================
@@ -0,0 +1,2 @@
+
+loaded = True


=====================================
testsuite/tests/ghci/should_run/T24115.script
=====================================
@@ -0,0 +1 @@
+loaded


=====================================
testsuite/tests/ghci/should_run/all.T
=====================================
@@ -92,3 +92,6 @@ test('T22958b', just_ghci, compile_and_run, [''])
 test('T22958c', just_ghci, compile_and_run, [''])
 test('GhciMainIs', just_ghci, compile_and_run, ['-main-is otherMain'])
 test('LargeBCO', [extra_files(['LargeBCO_A.hs']), req_interp, extra_hc_opts("-O -fbyte-code-and-object-code -fprefer-byte-code")], compile_and_run, [''])
+
+test('T24115', just_ghci + [extra_run_opts("-e ':add T24115.hs'")], ghci_script, ['T24115.script'])
+



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d561073727186c7b456c9ef113ccb7fc0df4560e

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d561073727186c7b456c9ef113ccb7fc0df4560e
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20231206/f07231b5/attachment-0001.html>


More information about the ghc-commits mailing list