From c78344ef0488c9091b7fc9f2af5c5e1059ace2c0 Mon Sep 17 00:00:00 2001 From: yuyi Date: Sun, 18 Sep 2022 19:09:31 +0800 Subject: [PATCH] vrepl: fix output errors (fix #15801) (#15804) --- cmd/tools/vrepl.v | 4 +++- vlib/v/tests/repl/error_and_continue_print.repl | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 vlib/v/tests/repl/error_and_continue_print.repl diff --git a/cmd/tools/vrepl.v b/cmd/tools/vrepl.v index aa92f4ad90..02c7c8290b 100644 --- a/cmd/tools/vrepl.v +++ b/cmd/tools/vrepl.v @@ -494,7 +494,9 @@ fn run_repl(workdir string, vrepl_prefix string) int { } if s.output.len > r.last_output.len { len := r.last_output.len - r.last_output = s.output.clone() + if s.exit_code == 0 { + r.last_output = s.output.clone() + } cur_line_output := s.output[len..] print_output(cur_line_output) } diff --git a/vlib/v/tests/repl/error_and_continue_print.repl b/vlib/v/tests/repl/error_and_continue_print.repl new file mode 100644 index 0000000000..3cfc0bfbf6 --- /dev/null +++ b/vlib/v/tests/repl/error_and_continue_print.repl @@ -0,0 +1,15 @@ +a = 3 +b +[4, 5].filter(it < 5) +===output=== +error: undefined ident: `a` (use `:=` to declare a variable) + 5 | import math + 6 | + 7 | a = 3 + | ^ +error: undefined ident: `b` + 5 | import math + 6 | + 7 | println(b) + | ^ +[4]