Commit 55e7ab12 authored by gintas's avatar gintas Committed by Joachim Breitner

Do not print the result of 'main' after invoking ':main' (fixes #9086).

parent fa8553de
......@@ -1141,9 +1141,10 @@ runMain s = case toArgs s of
Left err -> liftIO (hPutStrLn stderr err)
Right args ->
do dflags <- getDynFlags
case mainFunIs dflags of
Nothing -> doWithArgs args "main"
Just f -> doWithArgs args f
let main = fromMaybe "main" (mainFunIs dflags)
-- Wrap the main function in 'void' to discard its value instead
-- of printing it (#9086). See Haskell 2010 report Chapter 5.
doWithArgs args $ "Control.Monad.void (" ++ main ++ ")"
-----------------------------------------------------------------------------
-- :run
......
......@@ -30,3 +30,5 @@ T3890:
T7299:
'$(TEST_HC)' $(TEST_HC_OPTS) -ignore-dot-ghci -e "Control.Concurrent.threadDelay (1000 * 1000)"
T9086:
'$(TEST_HC)' $(TEST_HC_OPTS) -ignore-dot-ghci -e ":main" T9086.hs
main = return "this should not be printed"
......@@ -14,3 +14,4 @@ test('T2228',
test('T2636', req_interp, run_command, ['$MAKE --no-print-directory -s T2636'])
test('T3890', req_interp, run_command, ['$MAKE --no-print-directory -s T3890'])
test('T7299', req_interp, run_command, ['$MAKE --no-print-directory -s T7299'])
test('T9086', req_interp, run_command, ['$MAKE --no-print-directory -s T9086'])
let main = do { putStrLn "hello"; return "discarded" }
:main
......@@ -175,3 +175,4 @@ test('T8931', normal, ghci_script, ['T8931.script'])
test('T8959', normal, ghci_script, ['T8959.script'])
test('T8959b', expect_broken(8959), ghci_script, ['T8959b.script'])
test('T9181', normal, ghci_script, ['T9181.script'])
test('T9086b', normal, ghci_script, ['T9086b.script'])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment