neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit aaacfd4a6d8f43367f7fb3ba8d81baad3fde6c8e
parent 85a7f9dabe0bcd6a1b3a0941f0bc0d1983b01888
Author: zeertzjq <zeertzjq@outlook.com>
Date:   Fri, 14 Apr 2023 17:06:52 +0800

vim-patch:8.2.1512: failure after trinary expression fails

Problem:    Failure after trinary expression fails.
Solution:   Restore eval_flags. (Yasuhiro Matsumoto, closes vim/vim#6776)

https://github.com/vim/vim/commit/69e44552c567ff25b363ba0790ad3d43fa0397a7

Co-authored-by: Bram Moolenaar <Bram@vim.org>

Diffstat:
Msrc/nvim/eval.c | 5++++-
Mtest/old/testdir/test_vimscript.vim | 24++++++++++++++++++++++++
2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/src/nvim/eval.c b/src/nvim/eval.c @@ -2378,6 +2378,7 @@ int eval1(char **arg, typval_T *rettv, evalarg_T *const evalarg) *arg = skipwhite(*arg + 1); evalarg_used->eval_flags = result ? orig_flags : orig_flags & ~EVAL_EVALUATE; if (eval1(arg, rettv, evalarg_used) == FAIL) { + evalarg_used->eval_flags = orig_flags; return FAIL; } @@ -2388,17 +2389,19 @@ int eval1(char **arg, typval_T *rettv, evalarg_T *const evalarg) if (evaluate && result) { tv_clear(rettv); } + evalarg_used->eval_flags = orig_flags; return FAIL; } // Get the third variable. Recursive! *arg = skipwhite(*arg + 1); - typval_T var2; evalarg_used->eval_flags = !result ? orig_flags : orig_flags & ~EVAL_EVALUATE; + typval_T var2; if (eval1(arg, &var2, evalarg_used) == FAIL) { if (evaluate && result) { tv_clear(rettv); } + evalarg_used->eval_flags = orig_flags; return FAIL; } if (evaluate && !result) { diff --git a/test/old/testdir/test_vimscript.vim b/test/old/testdir/test_vimscript.vim @@ -7258,6 +7258,30 @@ func Test_typed_script_var() call StopVimInTerminal(buf) endfunc +" Test for issue6776 {{{1 +func Test_trinary_expression() + try + call eval('0 ? 0') + catch + endtry + " previous failure should not cause next expression to fail + call assert_equal(v:false, eval(string(v:false))) + + try + call eval('0 ? "burp') + catch + endtry + " previous failure should not cause next expression to fail + call assert_equal(v:false, eval(string(v:false))) + + try + call eval('1 ? 0 : "burp') + catch + endtry + " previous failure should not cause next expression to fail + call assert_equal(v:false, eval(string(v:false))) +endfunction + func Test_for_over_string() let res = '' for c in 'aéc̀d'