on master help sign in
Print error message if :exec'ed program exits with failure
8e2aff5Ilya Yanok
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+
1# New in 1.2.0
6# New in 1.2.0
2
7
3## Language updates
8## Language updates
src/Idris/REPL.hs+11−2
@@ -1264,8 +1264,17 @@ process fn (Execute tm)
1264 ir <- compile t tmpn (Just m)
1264 ir <- compile t tmpn (Just m)
1265 runIO $ generate t (fst (head (idris_imported ist))) ir
1265 runIO $ generate t (fst (head (idris_imported ist))) ir
1266 case idris_outputmode ist of
1266 case idris_outputmode ist of
1267+ RawOutput h ->
1267− RawOutput h -> do runIO $ rawSystem progName []
1268+ do res <- runIO $ rawSystem progName []
1269+ case res of
1268− return ()
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
1269 IdeMode n h -> runIO . hPutStrLn h $
1278 IdeMode n h -> runIO . hPutStrLn h $
1270 IdeMode.convSExp "run-program" tmpn n)
1279 IdeMode.convSExp "run-program" tmpn n)
1271 (\e -> getIState >>= iRenderError . flip pprintErr e)
1280 (\e -> getIState >>= iRenderError . flip pprintErr e)