From b1fefc5e0c5f2a4185da77bdbab62249bab89043 Mon Sep 17 00:00:00 2001 From: yuyi Date: Mon, 19 May 2025 19:02:32 +0800 Subject: [PATCH] repl: fix typeof(a) with warning (fix #24499) (#24515) --- cmd/tools/vrepl.v | 8 ++-- .../slow_tests/repl/print_output_warning.repl | 44 +++++++++++++++++++ 2 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 vlib/v/slow_tests/repl/print_output_warning.repl diff --git a/cmd/tools/vrepl.v b/cmd/tools/vrepl.v index 94b1366b1..4c5eb3623 100644 --- a/cmd/tools/vrepl.v +++ b/cmd/tools/vrepl.v @@ -533,7 +533,7 @@ fn run_repl(workdir string, vrepl_prefix string) int { if s.output.len > r.last_output.len { cur_line_output := s.output[r.last_output.len..] print_output(cur_line_output) - if s.exit_code == 0 { + if s.exit_code == 0 && !cur_line_output.contains('warning:') { r.last_output = s.output.clone() r.lines << r.line } @@ -583,8 +583,10 @@ fn run_repl(workdir string, vrepl_prefix string) int { if s.output.len > r.last_output.len { cur_line_output := s.output[r.last_output.len..] print_output(cur_line_output) - r.last_output = s.output.clone() - r.lines << print_line + if !cur_line_output.contains('warning:') { + r.last_output = s.output.clone() + r.lines << print_line + } } continue } else { diff --git a/vlib/v/slow_tests/repl/print_output_warning.repl b/vlib/v/slow_tests/repl/print_output_warning.repl new file mode 100644 index 000000000..a5c79e098 --- /dev/null +++ b/vlib/v/slow_tests/repl/print_output_warning.repl @@ -0,0 +1,44 @@ +a := error('hi') +typeof(a) +typeof(a) +typeof(a) +print(typeof(a)) +print(typeof(a)) +print(typeof(a)) +===output=== +warning: use e.g. `typeof(expr).name` or `sum_type_instance.type_name()` instead + 6 | + 7 | a := error('hi') + 8 | println(typeof(a)) + | ~~~~~~ +IError +warning: use e.g. `typeof(expr).name` or `sum_type_instance.type_name()` instead + 6 | + 7 | a := error('hi') + 8 | println(typeof(a)) + | ~~~~~~ +IError +warning: use e.g. `typeof(expr).name` or `sum_type_instance.type_name()` instead + 6 | + 7 | a := error('hi') + 8 | println(typeof(a)) + | ~~~~~~ +IError +warning: use e.g. `typeof(expr).name` or `sum_type_instance.type_name()` instead + 6 | + 7 | a := error('hi') + 8 | print(typeof(a)) + | ~~~~~~ +IError +warning: use e.g. `typeof(expr).name` or `sum_type_instance.type_name()` instead + 6 | + 7 | a := error('hi') + 8 | print(typeof(a)) + | ~~~~~~ +IError +warning: use e.g. `typeof(expr).name` or `sum_type_instance.type_name()` instead + 6 | + 7 | a := error('hi') + 8 | print(typeof(a)) + | ~~~~~~ +IError \ No newline at end of file -- 2.39.5