Skip to content

Commit

Permalink
Early abort of pipeline in REPL (#67)
Browse files Browse the repository at this point in the history
Fixes #66
  • Loading branch information
ppolesiuk authored May 8, 2024
1 parent 56eec70 commit 3416da7
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/DblParser/Main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ let make_nowhere data =
}

let rec repl_seq imported () =
InterpLib.Error.wrap_repl_cont (repl_seq_main imported) ()

and repl_seq_main imported () =
flush stderr;
Printf.printf "> %!";
let lexbuf = Lexing.from_channel stdin in
Expand Down
5 changes: 5 additions & 0 deletions src/InterpLib/Error.ml
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,10 @@ let assert_no_error () =
if !err_counter <> 0 then
raise Fatal_error

let wrap_repl_cont cont () =
let v = cont () in
assert_no_error ();
v

let reset () =
err_counter := 0
5 changes: 5 additions & 0 deletions src/InterpLib/Error.mli
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,10 @@ val report : ?pos:Position.t -> cls:error_class -> string -> unit
of each phase. *)
val assert_no_error : unit -> unit

(** Wrap REPL continuation around additional call of [assert_no_error]. This
function should be used in transforming REPL continuations (e.g. those
stored in [Surface.ERepl]) in each phase that may raise an error. *)
val wrap_repl_cont : (unit -> 'a) -> unit -> 'a

(** Reset state of reported errors. Used in REPL in case of an error. *)
val reset : unit -> unit
2 changes: 1 addition & 1 deletion src/TypeInference/Expr.ml
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ let rec check_repl_def_seq ~tcfix env ienv def_seq tp eff =
in
let e =
{ T.pos = Position.nowhere;
T.data = T.ERepl(func, tp, eff)
T.data = T.ERepl(InterpLib.Error.wrap_repl_cont func, tp, eff)
} in
e

Expand Down

0 comments on commit 3416da7

Please sign in to comment.