fixes #18411 (closed) #9916 (closed) #17560 (closed)
GHCi UI code was updated to exit/fail with error code 1 if something has gone wrong in expression evaluation mode. This makes sense because this meets expectations/necessities of users that use this mode when writing scripts.
A few things were introduced to implement this:
- Previously, a Bool data type was used to make decision whether execution should fail (
ghc -e
) or continue (regular repl mode). Instead of bland Bool new ADT was introduced to denote the outcome of ghci command execution:
data CmdExecOutcome
= CleanExit
| CmdSuccess
| CmdFailure
This is now used as a return type in many command actions. I only scratched the surface and wasn't able to rip out this Bool. If this design is acceptable, I will create a follow-up ticket to eliminate this Bool entirely and replace it with newly introduced ADT (this implies refactoring runOneCommand
, runStmt
and friends).
-
A few new helpers were introduced and scattered where necessary to ensure the desired execution outcome. The idea is to check
GHCi
state (specifically, theghc_e
field) and conditionally throw ExitFailure. -
Regression tests were added to check all necessary code paths.