diff --git a/cmd/tools/vrepl.v b/cmd/tools/vrepl.v index 41a79ea5c750e9..e36424127fe43a 100644 --- a/cmd/tools/vrepl.v +++ b/cmd/tools/vrepl.v @@ -353,15 +353,6 @@ fn run_repl(workdir string, vrepl_prefix string) int { if line.len <= -1 || line == 'exit' { break } - if exit_pos := line.index('exit') { - oparen := line[(exit_pos + 4)..].trim_space() - if oparen.starts_with('(') { - if closing := oparen.index(')') { - rc := oparen[1..closing].parse_int(0, 8) or { panic(err) } - return int(rc) - } - } - } r.line = line if r.line == '\n' { continue @@ -470,6 +461,10 @@ fn run_repl(workdir string, vrepl_prefix string) int { if oline.starts_with(' ') { is_statement = true } + // The parentheses do not match + if r.line.count('(') != r.line.count(')') { + is_statement = true + } if !is_statement && (!func_call || fntype == FnType.fn_type) && r.line != '' { temp_line = 'println(${r.line})' source_code := r.current_source_code(false, false) + '\n${temp_line}\n' diff --git a/vlib/v/slow_tests/repl/error_eval_script.repl b/vlib/v/slow_tests/repl/error_eval_script.repl new file mode 100644 index 00000000000000..316944a93a3864 --- /dev/null +++ b/vlib/v/slow_tests/repl/error_eval_script.repl @@ -0,0 +1,7 @@ +"text") exit(-1) +===output=== +error: expression evaluated but not used + 5 | import math + 6 | + 7 | "text") exit(-1) + | ~~~~~~