From a0c8ad73985bba1172ec80e5c8b66e5580965ef6 Mon Sep 17 00:00:00 2001 From: Shivanjan Chakravorty Date: Tue, 7 Jan 2020 16:56:49 +0530 Subject: [PATCH] post increment/decrement repl fix --- tools/vrepl.v | 9 ++++++++- vlib/compiler/tests/repl/postfix_operators.repl | 11 +++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 vlib/compiler/tests/repl/postfix_operators.repl diff --git a/tools/vrepl.v b/tools/vrepl.v index 5749c54087..ad885fbe0e 100644 --- a/tools/vrepl.v +++ b/tools/vrepl.v @@ -151,7 +151,14 @@ pub fn run_repl() []string { mut temp_line := r.line mut temp_flag := false func_call := r.function_call(r.line) - if !(r.line.contains(' ') || r.line.contains(':') || r.line.contains('=') || r.line.contains(',') || r.line == '') && !func_call { + if !( + r.line.contains(' ') || + r.line.contains(':') || + r.line.contains('=') || + r.line.contains(',') || + r.line.ends_with('++') || + r.line.ends_with('--') || + r.line == '') && !func_call { temp_line = 'println($r.line)' temp_flag = true } diff --git a/vlib/compiler/tests/repl/postfix_operators.repl b/vlib/compiler/tests/repl/postfix_operators.repl new file mode 100644 index 0000000000..92b4db9fd6 --- /dev/null +++ b/vlib/compiler/tests/repl/postfix_operators.repl @@ -0,0 +1,11 @@ +mut a := 2 +a++ +a +println(a) +println(a++) +a +===output=== +3 +3 +3 +3