From 510500d21bb7ba298ecfd4d98d7510311be7dd0e Mon Sep 17 00:00:00 2001 From: yuyi Date: Sat, 13 Jul 2024 17:34:20 +0800 Subject: [PATCH] vrepl: fix error of undefined ident (#21861) --- cmd/tools/vrepl.v | 8 ++++++++ vlib/v/slow_tests/repl/error_and_continue_print.repl | 6 +++--- vlib/v/slow_tests/repl/error_exitasdfasdf.repl | 6 +++--- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/cmd/tools/vrepl.v b/cmd/tools/vrepl.v index a79fb671a..2a04ae5cb 100644 --- a/cmd/tools/vrepl.v +++ b/cmd/tools/vrepl.v @@ -472,6 +472,14 @@ fn run_repl(workdir string, vrepl_prefix string) int { r.lines << print_line } continue + } else { + if s.output.len > r.last_output.len { + cur_line_output := s.output[r.last_output.len..] + if cur_line_output.contains('undefined ident:') { + print_output(cur_line_output) + continue + } + } } } mut temp_source_code := '' diff --git a/vlib/v/slow_tests/repl/error_and_continue_print.repl b/vlib/v/slow_tests/repl/error_and_continue_print.repl index 579805c9c..3cfc0bfbf 100644 --- a/vlib/v/slow_tests/repl/error_and_continue_print.repl +++ b/vlib/v/slow_tests/repl/error_and_continue_print.repl @@ -7,9 +7,9 @@ error: undefined ident: `a` (use `:=` to declare a variable) 6 | 7 | a = 3 | ^ -error: `b` evaluated but not used +error: undefined ident: `b` 5 | import math 6 | - 7 | b - | ^ + 7 | println(b) + | ^ [4] diff --git a/vlib/v/slow_tests/repl/error_exitasdfasdf.repl b/vlib/v/slow_tests/repl/error_exitasdfasdf.repl index 17abea446..a026a8ee1 100644 --- a/vlib/v/slow_tests/repl/error_exitasdfasdf.repl +++ b/vlib/v/slow_tests/repl/error_exitasdfasdf.repl @@ -1,7 +1,7 @@ exitasdfasdf ===output=== -error: `exitasdfasdf` evaluated but not used +error: undefined ident: `exitasdfasdf` 5 | import math 6 | - 7 | exitasdfasdf - | ~~~~~~~~~~~~ + 7 | println(exitasdfasdf) + | ~~~~~~~~~~~~ -- 2.39.5