on master help sign in
Print error message if :exec'ed program exits with failure

Check the result code of the compiled program and print an error message if it didn't return success.

commit8e2aff5c837a4cc06e0d6863b3d89f9ae05a4102 authorIlya Yanok <ilya.yanok@gmail.com> dateSun 4 Feb 2018, 18:16 (9 years ago) parent1d19304
2 files changed+16−2
CHANGELOG.md+5 src/Idris/REPL.hs+11−2
CHANGELOG.md+5
@@ -1,3 +1,8 @@
1+# New in 1.2.*
2+
3++ REPL now prints an error message if program compiled by `:exec` terminates
4+ abnormally.
5+
16# New in 1.2.0
27
38## Language updates
src/Idris/REPL.hs+11−2
@@ -1264,8 +1264,17 @@ process fn (Execute tm)
12641264 ir <- compile t tmpn (Just m)
12651265 runIO $ generate t (fst (head (idris_imported ist))) ir
12661266 case idris_outputmode ist of
1267− RawOutput h -> do runIO $ rawSystem progName []
1268− return ()
1267+ RawOutput h ->
1268+ do res <- runIO $ rawSystem progName []
1269+ case res of
1270+ ExitSuccess -> return ()
1271+ ExitFailure err ->
1272+ ifail $ "Compiled program " ++
1273+ if err < 0
1274+ then "was killed by signal " ++
1275+ show (0 - err)
1276+ else "terminated with exit code " ++
1277+ show err
12691278 IdeMode n h -> runIO . hPutStrLn h $
12701279 IdeMode.convSExp "run-program" tmpn n)
12711280 (\e -> getIState >>= iRenderError . flip pprintErr e)